set() public static method

Set the named value in the cache with an expiration.
public static set ( mixed $name, mixed $value, integer $expiry = 3600, boolean $keep = false )
$name mixed The name of the cached item or an array of array( string $group, string $name )
$value mixed The value to store
$expiry integer Number of second after the call that the cache will expire
$keep boolean If true, retain the cache value even after expiry but report the cache as expired
Esempio n. 1
0
 /**
  * Handle incoming requests for the introspection document
  */
 public function act_introspection()
 {
     Utils::check_request_method(array('GET', 'HEAD', 'POST'));
     $cache_xml = null;
     if (Cache::has('atom:introspection:xml')) {
         $cache_xml = Cache::get('atom:introspection:xml');
         $cache_xml = simplexml_load_string($cache_xml);
     }
     if ($cache_xml instanceof SimpleXMLElement) {
         $xml = $cache_xml;
     } else {
         $xml = new SimpleXMLElement('<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"></service>');
         $service_workspace = $xml->addChild('workspace');
         $workspace_title = $service_workspace->addChild('atom:title', Utils::htmlspecialchars(Options::get('title')), 'http://www.w3.org/2005/Atom');
         $workspace_collection = $service_workspace->addChild('collection');
         $workspace_collection->addAttribute('href', URL::get('atom_feed', 'index=1'));
         $collection_title = $workspace_collection->addChild('atom:title', 'Blog Entries', 'http://www.w3.org/2005/Atom');
         $collection_accept = $workspace_collection->addChild('accept', 'application/atom+xml;type=entry');
         Cache::set('atom:introspection:xml', $xml->asXML());
     }
     Plugins::act('atom_introspection', $xml, $this->handler_vars);
     $xml = $xml->asXML();
     ob_clean();
     header('Content-Type: application/atomsvc+xml');
     print $xml;
 }
Esempio n. 2
0
 /**
  * Get the Defensio stats.
  * @todo use cron to get stats, and "keep cache" system
  * @return DefensioResponse The stats. Or NULL if no respnse.
  */
 public function get_defensio_stats()
 {
     if (Cache::has('defensio_stats')) {
         $stats = Cache::get('defensio_stats');
     } else {
         try {
             $stats = $this->defensio->get_stats();
             Cache::set('defensio_stats', $stats);
         } catch (Exception $e) {
             EventLog::log($e->getMessage(), 'notice', 'theme', 'Defensio');
             return NULL;
         }
     }
     return $stats;
 }