Class FileEngine
File Storage engine for cache. Filestorage is the slowest cache storage to read and write. However, it is good for servers that don't have other storage engine available, or have content which is not performance sensitive.
You can configure a FileEngine cache, using Cache::config()
- CacheEngine
- FileEngine
Copyright: Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Cache/Engine/FileEngine.php
Properties summary
Method Summary
-
_active() protected
Determine is cache directory is writable -
_setKey() protected
Sets the current cache key this class is managing, and creates a writable SplFileObject for the cache file the key is referring to.
-
clear() public
Delete all values from the cache -
decrement() public
Not implemented -
delete() public
Delete a key from the cache -
gc() public
Garbage collection. Permanently remove all expired and deleted data -
increment() public
Not implemented -
init() public
Initialize the Cache Engine -
read() public
Read a key from the cache -
write() public
Write data for key into cache
Method Detail
_setKey() protected ¶
_setKey( string $key , boolean $createKey = false )
Sets the current cache key this class is managing, and creates a writable SplFileObject for the cache file the key is referring to.
Parameters
- string $key
- The key
- boolean $createKey optional false
- Whether the key should be created if it doesn't exists, or not
Returns
true if the cache key could be set, false otherwise
clear() public ¶
clear( boolean $check )
Delete all values from the cache
Parameters
- boolean $check
- Optional - only delete expired cache items
Returns
True if the cache was successfully cleared, false otherwise
delete() public ¶
delete( string $key )
Delete a key from the cache
Parameters
- string $key
- Identifier for the data
Returns
True if the value was successfully deleted, false if it didn't exist or couldn't be removed
gc() public ¶
gc( )
Garbage collection. Permanently remove all expired and deleted data
Returns
True if garbage collection was successful, false on failure
Overrides
init() public ¶
init( array $settings = array() )
Initialize the Cache Engine
Called automatically by the cache frontend To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
Parameters
- array $settings optional array()
- array of setting for the engine
Returns
True if the engine has been successfully initialized, false if not
Overrides
read() public ¶
read( string $key )
Read a key from the cache
Parameters
- string $key
- Identifier for the data
Returns
The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
write() public ¶
write( string $key , mixed $data , mixed $duration )
Write data for key into cache
Parameters
- string $key
- Identifier for the data
- mixed $data
- Data to be cached
- mixed $duration
- How long to cache the data, in seconds
Returns
True if the data was successfully cached, false on failure