Example #1
0
 /**
  * Sets a given key in the cache. If the data group is unknown, a Warning-Level error
  * is logged and putting is denied.
  *
  * @param string $data_group The Data Group to look in.
  * @param string $key The key to look up.
  * @param mixed $data The data to store.
  * @param int $timeout how long the data should live in the cache.
  */
 function put($data_group, $key, $data, $timeout = false)
 {
     if ($this->_cache === null) {
         return;
     }
     if (!in_array($data_group, $this->_data_groups)) {
         debug_add("Tried to add data to the unknown data group {$data_group}, cannot do that.", MIDCOM_LOG_WARN);
         debug_print_r('Known data groups:', $this->_data_groups);
         debug_print_function_stack('We were called from here:');
         return;
     }
     $this->_cache->put("{$data_group}-{$key}", $data, $timeout);
 }
Example #2
0
 /**
  * Sets a given leave key in the cache
  *
  * @param string $key The key to look up.
  * @param mixed $data The data to store.
  * @param int $timeout how long the data should live in the cache.
  */
 public function put_leaves($key, $data, $timeout = false)
 {
     if ($this->_cache === null) {
         return;
     }
     $lang_id = midcom::get('i18n')->get_current_language();
     $result = $this->_cache->get("{$this->_prefix}-{$key}");
     if (!is_array($result)) {
         $result = array($lang_id => $data);
     } else {
         $result[$lang_id] = $data;
     }
     $this->_cache->put("{$this->_prefix}-{$key}", $result, $timeout);
 }
Example #3
0
 function store_dl_content(&$context, &$dl_config, &$dl_cache_data)
 {
     if ($this->_no_cache || $this->_live_mode) {
         return;
     }
     if ($this->_uncached) {
         return;
     }
     $dl_request_id = 'DL' . $this->generate_request_identifier($context, $dl_config);
     /**
     * See the FIXME in generate_content_identifier on why we use the content hash
             $dl_content_id = $this->generate_content_identifier($context);
     */
     $dl_content_id = 'DLC-' . md5($dl_cache_data);
     $dl_entry_data = array();
     if (!is_null($this->_expires)) {
         $dl_entry_data['expires'] = $this->_expires;
     } else {
         // Use default expiry for cache entry, most components don't bother calling expires() properly
         $dl_entry_data['expires'] = time() + $this->_default_lifetime;
     }
     $this->_meta_cache->open(true);
     $this->_data_cache->open(true);
     $this->_meta_cache->put($dl_request_id, $dl_content_id);
     $this->_meta_cache->put($dl_content_id, $dl_entry_data);
     unset($dl_entry_data);
     $this->_data_cache->put($dl_content_id, $dl_cache_data);
     // Cache where the object have been
     $this->store_context_guid_map($context, $dl_content_id, $dl_request_id);
     $this->_meta_cache->close();
     $this->_data_cache->close();
     unset($dl_cache_data, $dl_content_id, $dl_request_id);
 }