d and written to a file with a * header indicating the expiration time. File locking can be used for write operations if enabled. * * @param string $key An MD5 of the DB query. * @param mixed $content Data to be cached. * @param int $expiration Optional. Time in seconds until the cache entry expires. Default is 0 (no expiration). * @param string $group Optional. The group to which the cache belongs. Default is an empty string. * * @return bool True on success, false on failure. */ public function set( $key, $content, $expiration = 0, $group = '' ) { /** * Get the file pointer of the cache file. * The $key is transformed to a storage key (format "w3tc_INSTANCEID_HOST_BLOGID_dbcache_HASH"). * The file path is in the format: CACHEDIR/db/BLOGID/GROUP/[0-9a-f]{3}/[0-9a-f]{3}/[0-9a-f]{32}. */ $fp = $this->fopen_write( $key, $group, 'wb' ); if ( ! $fp ) { return false; } if ( $this->_locking ) { @flock( $fp, LOCK_EX ); } if ( $expiration <= 0 || $expiration > W3TC_CACHE_FILE_EXPIRE_MAX ) { $expiration = W3TC_CACHE_FILE_EXPIRE_MAX; } $expires_at = time() + $expiration; @fputs( $fp, pack( 'L', $expires_at ) ); @fputs( $fp, '