Class Phalcon\Cache\Frontend\None

implements Phalcon\Cache\FrontendInterface

Source on GitHub

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(
  8. $frontCache,
  9. [
  10. "host" => "localhost",
  11. "port" => "11211",
  12. ]
  13. );
  14. $cacheKey = "robots_order_id.cache";
  15. // This Frontend always return the data as it's returned by the backend
  16. $robots = $cache->get($cacheKey);
  17. if ($robots === null) {
  18. // This cache doesn't perform any expiration checking, so the data is always expired
  19. // Make the database call and populate the variable
  20. $robots = Robots::find(
  21. [
  22. "order" => "id",
  23. ]
  24. );
  25. $cache->save($cacheKey, $robots);
  26. }
  27. // Use $robots :)
  28. foreach ($robots as $robot) {
  29. echo $robot->name, "\n";
  30. }

Methods

public getLifetime ()

Returns cache lifetime, always one second expiring content

public 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