Exemplo n.º 1
0
 public function save($cacheUrl, Kwf_Component_Data $data)
 {
     $this->_redis->sAdd('urlids:pageid:' . $data->getPage()->componentId, 'url:' . $cacheUrl);
     $this->_redis->sAdd('urlids:expandedid:' . $data->getExpandedComponentId(), 'url:' . $cacheUrl);
     $parts = preg_split('/([_\\-])/', $data->getExpandedComponentId(), -1, PREG_SPLIT_DELIM_CAPTURE);
     $id = '';
     foreach ($parts as $part) {
         $id .= $part;
         if ($part != '-' && $part != '_' && $id != 'root') {
             $this->_redis->sAdd('urlids:recexpandedid:' . $id, 'url:' . $cacheUrl);
         }
     }
     $this->_redis->setEx('url:' . $cacheUrl, 365 * 24 * 60 * 60, serialize($data->kwfSerialize()));
 }
 public function updateFromPage(Kwf_Component_Data $page)
 {
     $this->deleted = !$page->isVisible();
     $this->page_id = $page->componentId;
     $this->expanded_component_id = $page->getExpandedComponentId();
     $this->domain_component_id = $page->getDomainComponent()->componentId;
     $this->subroot_component_id = $page->getSubroot()->componentId;
     $this->url = $page->getAbsoluteUrl();
     $this->meta_noindex = $this->_getMetaNoIndex($page);
     $this->fulltext_skip = $this->_getFulltextSkip($page);
 }
Exemplo n.º 3
0
 public function save(Kwf_Component_Data $component, $content, $renderer, $type, $value, $tag, $lifetime)
 {
     $microtime = $this->_getMicrotime();
     // MySQL
     $data = array('component_id' => (string) $component->componentId, 'db_id' => (string) $component->dbId, 'page_db_id' => (string) $component->getPageOrRoot()->dbId, 'expanded_component_id' => (string) $component->getExpandedComponentId(), 'component_class' => $component->componentClass, 'renderer' => $renderer, 'type' => $type, 'value' => (string) $value, 'tag' => (string) $tag, 'microtime' => $microtime, 'expire' => is_null($lifetime) ? null : time() + $lifetime, 'deleted' => false, 'content' => $content);
     $options = array('buffer' => true, 'replace' => true, 'skipModelObserver' => true);
     $this->getModel('cache')->import(Kwf_Model_Abstract::FORMAT_ARRAY, array($data), $options);
     // APC
     $cacheId = $this->_getCacheId($component->componentId, $renderer, $type, $value);
     $ttl = null;
     if ($lifetime) {
         $ttl = $lifetime;
     }
     Kwf_Component_Cache_Memory::getInstance()->save($content, $cacheId, $ttl, $microtime);
     return true;
 }
Exemplo n.º 4
0
 public function save(Kwf_Component_Data $component, $contents, $renderer, $type, $value, $tag, $lifetime)
 {
     $key = self::_getCacheId($component->componentId, $renderer, $type, $value);
     $setKey = $key;
     //key that will be stored in sets
     if ($type == 'fullPage') {
         $setKey .= ':' . $component->getDomainComponentId() . ':' . $component->url;
     }
     $this->_redis->sAdd('viewids:componentid:' . $component->componentId, $setKey);
     $this->_redis->sAdd('viewids:dbid:' . $component->dbId, $setKey);
     $this->_redis->sAdd('viewids:pagedbid:' . $component->getPageOrRoot()->dbId, $setKey);
     $this->_redis->sAdd('viewids:cls:' . $component->componentClass, $setKey);
     if ($tag) {
         $this->_redis->sAdd('viewids:tag:' . $tag, $setKey);
     }
     $parts = preg_split('/([_\\-])/', $component->getExpandedComponentId(), -1, PREG_SPLIT_DELIM_CAPTURE);
     $id = '';
     foreach ($parts as $part) {
         $id .= $part;
         if ($part != '-' && $part != '_' && $id != 'root') {
             $this->_redis->sAdd('viewids:recexpandedid:' . $id, $setKey);
         }
     }
     $cacheContent = array('contents' => $contents, 'expire' => is_null($lifetime) ? null : time() + $lifetime);
     if (Kwf_Cache_Simple::getBackend() == 'memcache') {
         static $prefix;
         if (!isset($prefix)) {
             $prefix = Kwf_Cache_Simple::getUniquePrefix() . '-';
         }
         $ret = Kwf_Cache_Simple::getMemcache()->set($prefix . $key, $cacheContent, MEMCACHE_COMPRESSED, $lifetime);
     } else {
         if (is_null($lifetime)) {
             //Set a TTL for view contents http://stackoverflow.com/questions/16370278/how-to-make-redis-choose-lru-eviction-policy-for-only-some-of-the-keys
             $lifetime = 365 * 24 * 60 * 60;
         }
         $ret = $this->_redis->setEx($key, $lifetime, serialize($cacheContent));
     }
     return $ret;
 }
 public function updateFromPage(Kwf_Component_Data $page)
 {
     $this->deleted = !$page->isVisible();
     $this->page_id = $page->componentId;
     $this->expanded_component_id = $page->getExpandedComponentId();
     $domainCmp = $page->getDomainComponent();
     $this->domain_component_id = $domainCmp ? $domainCmp->componentId : null;
     $this->subroot_component_id = $page->getSubroot()->componentId;
     $this->url = $page->getAbsoluteUrl();
     if (!$this->url) {
         $this->url = '';
     }
     $this->sitemap_priority = '0.5';
     $this->sitemap_changefreq = 'weekly';
     $noindex = false;
     foreach ($page->getRecursiveChildComponents(array('flag' => 'hasPageMeta')) as $c) {
         $pageMeta = $c->getComponent()->getPageMeta();
         $this->sitemap_priority = $pageMeta['sitemap_priority'];
         $this->sitemap_changefreq = $pageMeta['sitemap_changefreq'];
         $noindex = $pageMeta['noindex'];
     }
     $this->meta_noindex = $noindex || $this->_getMetaNoIndex($page);
     $this->fulltext_skip = $this->_getFulltextSkip($page);
 }