lace as atomically as possible known value to new one */ public function set_if_maybe_equals( $key, $old_value, $new_value ) { // cant guarantee atomic action here, filelocks fail often $value = $this->get( $key ); if ( isset( $old_value['content'] ) && $value['content'] != $old_value['content'] ) return false; return $this->set( $key, $new_value ); } /** * Use key as a counter and add integet value to it */ public function counter_add( $key, $value ) { if ( $value == 0 ) return true; $fp = $this->fopen_write( $key, '', 'a' ); if ( !$fp ) return false; // use "x" to store increment, since it's most often case // and it will save 50% of size if only increments are used if ( $value == 1 ) @fputs( $fp, 'x' ); else @fputs( $fp, ' ' . (int)$value ); @fclose( $fp ); return true; } /** * Use key as a counter and add integet value to it */ public function counter_set( $key, $value ) { $fp = $this->fopen_write( $key, '', 'wb' ); if ( !$fp ) return false; $expire = W3TC_CACHE_FILE_EXPIRE_MAX; $expires_at = time() + $expire; @fputs( $fp, pack( 'L', $expires_at ) ); @fputs( $fp, '