Class Phalcon\Cache\Frontend\None

implements Phalcon\Cache\FrontendInterface

Discards any kind of frontend data input. This frontend does not have expiration time or any other options

  1. <?php
  2. <?php
  3. //Create a None Cache
  4. $frontCache = new \Phalcon\Cache\Frontend\None();
  5. // Create the component that will cache "Data" to a "Memcached" backend
  6. // Memcached connection settings
  7. $cache = new \Phalcon\Cache\Backend\Memcache($frontCache, array(
  8. "host" => "localhost",
  9. "port" => "11211"
  10. ));
  11. // This Frontend always return the data as it's returned by the backend
  12. $cacheKey = 'robots_order_id.cache';
  13. $robots = $cache->get($cacheKey);
  14. if ($robots === null) {
  15. // This cache doesn't perform any expiration checking, so the data is always expired
  16. // Make the database call and populate the variable
  17. $robots = Robots::find(array("order" => "id"));
  18. $cache->save($cacheKey, $robots);
  19. }
  20. // Use $robots :)
  21. foreach ($robots as $robot) {
  22. echo $robot->name, "\n";
  23. }

Methods

public int getLifetime ()

Returns cache lifetime, always one second expiring content

public boolean isBuffering ()

Check whether if frontend is buffering output, always false

public start ()

Starts output frontend

public string getContent ()

Returns output cached content

public stop ()

Stops output frontend

public beforeStore (mixed $data)

Prepare data to be stored

public afterRetrieve (mixed $data)

Prepares data to be retrieved to user