当前位置: 首页>>代码示例>>PHP>>正文


PHP common_memcache函数代码示例

本文整理汇总了PHP中common_memcache函数的典型用法代码示例。如果您正苦于以下问题:PHP common_memcache函数的具体用法?PHP common_memcache怎么用?PHP common_memcache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了common_memcache函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: blowCache

 function blowCache()
 {
     $cache = common_memcache();
     if ($cache) {
         $cache->delete(common_cache_key('notice_tag:notice_stream:' . $this->tag));
     }
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:7,代码来源:Notice_tag.php

示例2: handle

 function handle($args)
 {
     parent::handle($args);
     $c = common_memcache();
     if (!empty($c)) {
         $cacheKey = common_cache_key(MinifyPlugin::cacheKey . ':' . $this->file . '?v=' . empty($this->v) ? '' : $this->v);
         $out = $c->get($cacheKey);
     }
     if (empty($out)) {
         $out = $this->minify($this->file);
     }
     if (!empty($c)) {
         $c->set($cacheKey, $out);
     }
     $sec = session_cache_expire() * 60;
     header('Cache-Control: public, max-age=' . $sec);
     header('Pragma: public');
     $this->raw($out);
 }
开发者ID:himmelex,项目名称:NTW,代码行数:19,代码来源:minify.php

示例3: etag

 /**
  * etag for file
  *
  * This returns the same data (inode, size, mtime) as Apache would,
  * but in decimal instead of hex.
  *
  * @return string etag http header
  */
 function etag()
 {
     if (common_config('site', 'use_x_sendfile')) {
         return null;
     }
     $cache = common_memcache();
     if ($cache) {
         $key = common_cache_key('attachments:etag:' . $this->path);
         $etag = $cache->get($key);
         if ($etag === false) {
             $etag = crc32(file_get_contents($this->path));
             $cache->set($key, $etag);
         }
         return $etag;
     }
     $stat = stat($this->path);
     return '"' . $stat['ino'] . '-' . $stat['size'] . '-' . $stat['mtime'] . '"';
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:26,代码来源:getfile.php

示例4: get_option_value

  -k key       Key to look up; other args are ignored

ENDOFHELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
$karg = get_option_value('k');
if (!empty($karg)) {
    $k = common_cache_key($karg);
} else {
    $table = get_option_value('t');
    if (empty($table)) {
        die("No table or key specified\n");
    }
    $column = get_option_value('c');
    if (empty($column)) {
        $column = 'id';
    }
    $value = get_option_value('v');
    $k = Memcached_DataObject::cacheKey($table, $column, $value);
}
print "Checking key '{$k}'...\n";
$c = common_memcache();
if (empty($c)) {
    die("Can't initialize cache object!\n");
}
$obj = $c->get($k);
if (empty($obj)) {
    print "Empty.\n";
} else {
    var_dump($obj);
    print "\n";
}
开发者ID:Br3nda,项目名称:laconica,代码行数:31,代码来源:showcache.php

示例5: ini_set

}
ini_set("max_execution_time", "0");
ini_set("max_input_time", "0");
set_time_limit(0);
mb_internal_encoding('UTF-8');
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true);
require_once INSTALLDIR . '/lib/common.php';
$start_at = $argc > 1 ? $argv[1] : null;
common_log(LOG_INFO, 'Updating user inboxes.');
$user = new User();
if ($start_at) {
    $user->whereAdd('id >= ' . $start_at);
}
$cnt = $user->find();
$cache = common_memcache();
while ($user->fetch()) {
    common_log(LOG_INFO, 'Updating inbox for user ' . $user->id);
    $user->query('BEGIN');
    $inbox = new Notice_inbox();
    $result = $inbox->query('INSERT LOW_PRIORITY INTO notice_inbox (user_id, notice_id, created) ' . 'SELECT ' . $user->id . ', notice.id, notice.created ' . 'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' . 'WHERE subscription.subscriber = ' . $user->id . ' ' . 'AND notice.created >= subscription.created ' . 'AND NOT EXISTS (SELECT user_id, notice_id ' . 'FROM notice_inbox ' . 'WHERE user_id = ' . $user->id . ' ' . 'AND notice_id = notice.id)');
    if (is_null($result) || $result === false) {
        common_log_db_error($inbox, 'INSERT', __FILE__);
        continue;
    }
    $orig = clone $user;
    $user->inboxed = 1;
    $result = $user->update($orig);
    if (!$result) {
        common_log_db_error($user, 'UPDATE', __FILE__);
        continue;
开发者ID:Br3nda,项目名称:laconica,代码行数:31,代码来源:fixup_inboxes.php

示例6: memcache

 static function memcache()
 {
     return common_memcache();
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:4,代码来源:Memcached_DataObject.php

示例7: blowNoticeCount

 function blowNoticeCount()
 {
     $c = common_memcache();
     if (!empty($c)) {
         $c->delete(common_cache_key('profile:notice_count:' . $this->id));
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:7,代码来源:Profile.php

示例8: getCachedStream

 static function getCachedStream($qry, $cachekey, $offset, $limit, $order)
 {
     # If outside our cache window, just go to the DB
     if ($offset + $limit > NOTICE_CACHE_WINDOW) {
         return Notice::getStreamDirect($qry, $offset, $limit, null, null, $order, null);
     }
     # Get the cache; if we can't, just go to the DB
     $cache = common_memcache();
     if (!$cache) {
         return Notice::getStreamDirect($qry, $offset, $limit, null, null, $order, null);
     }
     # Get the notices out of the cache
     $notices = $cache->get(common_cache_key($cachekey));
     # On a cache hit, return a DB-object-like wrapper
     if ($notices !== false) {
         $wrapper = new ArrayWrapper(array_slice($notices, $offset, $limit));
         return $wrapper;
     }
     # If the cache was invalidated because of new data being
     # added, we can try and just get the new stuff. We keep an additional
     # copy of the data at the key + ';last'
     # No cache hit. Try to get the *last* cached version
     $last_notices = $cache->get(common_cache_key($cachekey) . ';last');
     if ($last_notices) {
         # Reverse-chron order, so last ID is last.
         $last_id = $last_notices[0]->id;
         # XXX: this assumes monotonically increasing IDs; a fair
         # bet with our DB.
         $new_notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW, $last_id, null, $order, null);
         if ($new_notice) {
             $new_notices = array();
             while ($new_notice->fetch()) {
                 $new_notices[] = clone $new_notice;
             }
             $new_notice->free();
             $notices = array_slice(array_merge($new_notices, $last_notices), 0, NOTICE_CACHE_WINDOW);
             # Store the array in the cache for next time
             $result = $cache->set(common_cache_key($cachekey), $notices);
             $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
             # return a wrapper of the array for use now
             return new ArrayWrapper(array_slice($notices, $offset, $limit));
         }
     }
     # Otherwise, get the full cache window out of the DB
     $notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW, null, null, $order, null);
     # If there are no hits, just return the value
     if (!$notice) {
         return $notice;
     }
     # Pack results into an array
     $notices = array();
     while ($notice->fetch()) {
         $notices[] = clone $notice;
     }
     $notice->free();
     # Store the array in the cache for next time
     $result = $cache->set(common_cache_key($cachekey), $notices);
     $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
     # return a wrapper of the array for use now
     $wrapper = new ArrayWrapper(array_slice($notices, $offset, $limit));
     return $wrapper;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:62,代码来源:Notice.php

示例9: repeatStream

 function repeatStream($limit = 100)
 {
     $cache = common_memcache();
     if (empty($cache)) {
         $ids = $this->_repeatStreamDirect($limit);
     } else {
         $idstr = $cache->get(common_cache_key('notice:repeats:' . $this->id));
         if ($idstr !== false) {
             $ids = explode(',', $idstr);
         } else {
             $ids = $this->_repeatStreamDirect(100);
             $cache->set(common_cache_key('notice:repeats:' . $this->id), implode(',', $ids));
         }
         if ($limit < 100) {
             // We do a max of 100, so slice down to limit
             $ids = array_slice($ids, 0, $limit);
         }
     }
     return Notice::getStreamByIds($ids);
 }
开发者ID:Br3nda,项目名称:statusnet-debian,代码行数:20,代码来源:Notice.php

示例10: incDeliveryCount

 /**
  * Update count of times we've re-encountered this message recently,
  * triggered when we get a message marked as 'redelivered'.
  *
  * Requires a CLI-friendly cache configuration.
  *
  * @param string $msgId message-id header from message
  * @return int number of retries recorded
  */
 function incDeliveryCount($msgId)
 {
     $count = 0;
     $cache = common_memcache();
     if ($cache) {
         $key = 'statusnet:stomp:message-retries:' . $msgId;
         $count = $cache->increment($key);
         if (!$count) {
             $count = 1;
             $cache->set($key, $count, null, 3600);
             $got = $cache->get($key);
         }
     }
     return $count;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:24,代码来源:stompqueuemanager.php

示例11: setCache

 function setCache($attrs, $loc)
 {
     $c = common_memcache();
     if (empty($c)) {
         return null;
     }
     $key = $this->cacheKey($attrs);
     $result = $c->set($key, $loc, 0, time() + $this->expiry);
     return $result;
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:10,代码来源:GeonamesPlugin.php

示例12: resetDb

 /**
  * Reconnect to the database for each child process,
  * or they'll get very confused trying to use the
  * same socket.
  */
 protected function resetDb()
 {
     // @fixme do we need to explicitly open the db too
     // or is this implied?
     global $_DB_DATAOBJECT;
     unset($_DB_DATAOBJECT['CONNECTIONS']);
     // Reconnect main memcached, or threads will stomp on
     // each other and corrupt their requests.
     $cache = common_memcache();
     if ($cache) {
         $cache->reconnect();
     }
     // Also reconnect memcached for status_network table.
     if (!empty(Status_network::$cache)) {
         Status_network::$cache->close();
         Status_network::$cache = null;
     }
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:23,代码来源:spawningdaemon.php

示例13: onStartStyleElement

 function onStartStyleElement($action, &$code, &$type, &$media)
 {
     if ($this->minifyInlineCss && $type == 'text/css') {
         $c = common_memcache();
         if (!empty($c)) {
             $cacheKey = common_cache_key(self::cacheKey . ':' . crc32($code));
             $out = $c->get($cacheKey);
         }
         if (empty($out)) {
             $out = $this->minifyCss($code);
         }
         if (!empty($c)) {
             $c->set($cacheKey, $out);
         }
         if (!empty($out)) {
             $code = $out;
         }
     }
 }
开发者ID:himmelex,项目名称:NTW,代码行数:19,代码来源:MinifyPlugin.php

示例14: subs_unsubscribe_to

function subs_unsubscribe_to($user, $other)
{
    if (!$user->isSubscribed($other)) {
        return _('Not subscribed!.');
    }
    $sub = DB_DataObject::factory('subscription');
    $sub->subscriber = $user->id;
    $sub->subscribed = $other->id;
    $sub->find(true);
    // note we checked for existence above
    if (!$sub->delete()) {
        return _('Couldn\'t delete subscription.');
    }
    $cache = common_memcache();
    if ($cache) {
        $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
    }
    return true;
}
开发者ID:Br3nda,项目名称:laconica,代码行数:19,代码来源:subs.php

示例15: get_ldap_connection

 function get_ldap_connection($config = null)
 {
     if ($config == null) {
         $config = $this->ldap_config;
     }
     $config_id = crc32(serialize($config));
     if (array_key_exists($config_id, self::$ldap_connections)) {
         $ldap = self::$ldap_connections[$config_id];
     } else {
         //cannot use Net_LDAP2::connect() as StatusNet uses
         //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
         //PEAR handling can be overridden on instance objects, so we do that.
         $ldap = new Net_LDAP2($config);
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err = $ldap->bind();
         if (Net_LDAP2::isError($err)) {
             // if we were called with a config, assume caller will handle
             // incorrect username/password (LDAP_INVALID_CREDENTIALS)
             if (isset($config) && $err->getCode() == 0x31) {
                 throw new LdapInvalidCredentialsException('Could not connect to LDAP server: ' . $err->getMessage());
             }
             throw new Exception('Could not connect to LDAP server: ' . $err->getMessage());
         }
         $c = common_memcache();
         if (!empty($c)) {
             $cacheObj = new MemcacheSchemaCache(array('c' => $c, 'cacheKey' => common_cache_key('ldap_schema:' . $config_id)));
             $ldap->registerSchemaCache($cacheObj);
         }
         self::$ldap_connections[$config_id] = $ldap;
     }
     return $ldap;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:32,代码来源:LdapCommon.php


注:本文中的common_memcache函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。