Example #1
0
 function blowCache($blowLast = false)
 {
     self::blow('notice_tag:notice_ids:%s', common_keyize($this->tag));
     if ($blowLast) {
         self::blow('notice_tag:notice_ids:%s;last', common_keyize($this->tag));
     }
 }
Example #2
0
 /**
  * Create a cache key from input text
  *
  * Builds a cache key from input text. Helps to namespace
  * the cache area (if shared with other applications or sites)
  * and prevent conflicts.
  *
  * @param string $extra the real part of the key
  *
  * @return string full key
  */
 static function key($extra)
 {
     $base_key = common_config('cache', 'base');
     if (empty($base_key)) {
         $base_key = common_keyize(common_config('site', 'name'));
     }
     return 'statusnet:' . $base_key . ':' . $extra;
 }
Example #3
0
 static function getStream($tag, $offset = 0, $limit = 20)
 {
     $qry = 'SELECT notice.* ' . 'FROM notice JOIN notice_tag ON notice.id = notice_tag.notice_id ' . "WHERE notice_tag.tag = '%s' ";
     return Notice::getStream(sprintf($qry, $tag), 'notice_tag:notice_stream:' . common_keyize($tag), $offset, $limit);
 }
Example #4
0
 static function cachedQuery($cls, $qry, $expiry = 3600)
 {
     $c = Memcached_DataObject::memcache();
     if (!$c) {
         $inst = new $cls();
         $inst->query($qry);
         return $inst;
     }
     $key_part = common_keyize($cls) . ':' . md5($qry);
     $ckey = common_cache_key($key_part);
     $stored = $c->get($ckey);
     if ($stored) {
         return new ArrayWrapper($stored);
     }
     $inst = new $cls();
     $inst->query($qry);
     $cached = array();
     while ($inst->fetch()) {
         $cached[] = clone $inst;
     }
     $inst->free();
     $c->set($ckey, $cached, MEMCACHE_COMPRESSED, $expiry);
     return new ArrayWrapper($cached);
 }
Example #5
0
 function clearTags()
 {
     $tag = new Notice_tag();
     $tag->notice_id = $this->id;
     if ($tag->find()) {
         while ($tag->fetch()) {
             self::blow('profile:notice_ids_tagged:%d:%s', $this->profile_id, common_keyize($tag->tag));
             self::blow('profile:notice_ids_tagged:%d:%s;last', $this->profile_id, common_keyize($tag->tag));
             self::blow('notice_tag:notice_ids:%s', common_keyize($tag->tag));
             self::blow('notice_tag:notice_ids:%s;last', common_keyize($tag->tag));
             $tag->delete();
         }
     }
     $tag->free();
 }
Example #6
0
function common_cache_key($extra)
{
    return 'laconica:' . common_keyize(common_config('site', 'name')) . ':' . $extra;
}
Example #7
0
 function cacheKey($attrs)
 {
     $key = 'geonames:' . implode(',', array_keys($attrs)) . ':' . common_keyize(implode(',', array_values($attrs)));
     if ($this->cachePrefix) {
         return $this->cachePrefix . ':' . $key;
     } else {
         return common_cache_key($key);
     }
 }