コード例 #1
0
 /**
  * Writes the cache data to storage.
  *
  * @param array	includes key, data, expires
  */
 protected function writeCache($cache)
 {
     $ptitle = $this->prefix . $cache['key'];
     try {
         $this->lock($cache['key']);
         $this->memcached->set($ptitle, $cache, $cache['expires']);
         if (!empty($cache['events'])) {
             foreach ($cache['events'] as $event) {
                 // store the cache information in memory so we can clear them.
                 if (empty($this->events[$event])) {
                     $this->events[$event] = array();
                 }
                 $this->events[$event][$cache['key']] = $cache['key'];
                 if (!$this->getEventTime($event)) {
                     // no events in memcached, set event time to 0
                     $this->setEventTime($event, 0);
                 }
             }
         }
         $this->unlock($cache['key']);
     } catch (Exception $e) {
         $this->unlock($cache['key']);
     }
 }