extends abstract class Phalcon\Cache\Backend
implements Phalcon\Cache\BackendInterface
Allows to cache output fragments using a file backend
use Phalcon\Cache\Backend\File; use Phalcon\Cache\Frontend\Output as FrontOutput; // Cache the file for 2 days $frontendOptions = [ "lifetime" => 172800, ]; // Create an output cache $frontCache = FrontOutput($frontOptions); // Set the cache directory $backendOptions = [ "cacheDir" => "../app/cache/", ]; // Create the File backend $cache = new File($frontCache, $backendOptions); $content = $cache->start("my-cache"); if ($content === null) { echo "<h1>", time(), "</h1>"; $cache->save(); } else { echo $content; }
Phalcon\Cache\Backend\File constructor
Returns a cached content
Stores cached content into the file backend and stops the frontend
Deletes a value from the cache by its key
Query the existing cached keys.
$cache->save("users-ids", [1, 2, 3]); $cache->save("projects-ids", [4, 5, 6]); var_dump($cache->queryKeys("users")); // ["users-ids"]
Checks if cache exists and it isn’t expired
Increment of a given key, by number $value
Decrement of a given key, by number $value
Immediately invalidates all existing items.
Return a file-system safe identifier for a given key
Set whether to use the safekey or not
...
...
...
...
...
...
Starts a cache. The keyname allows to identify the created fragment
Stops the frontend without store any cached content
Checks whether the last cache is fresh or cached
Checks whether the cache has starting buffering or not
Gets the last lifetime set
© 2011–2017 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/latest/api/Phalcon_Cache_Backend_File.html