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


PHP xcache_set函数代码示例

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


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

示例1: set

 /**
  * 写入缓存
  * @access public
  * @param string $name 缓存变量名
  * @param mixed $value  存储数据
  * @param integer $expire  有效时间(秒)
  * @return boolean
  */
 public function set($name, $value, $expire = null)
 {
     if (is_null($expire)) {
         $expire = $this->options['expire'];
     }
     $name = $this->options['prefix'] . $name;
     if (xcache_set($name, $value, $expire)) {
         if ($this->options['length'] > 0) {
             // 记录缓存队列
             $queue = xcache_get('__info__');
             if (!$queue) {
                 $queue = [];
             }
             if (false === array_search($name, $queue)) {
                 array_push($queue, $name);
             }
             if (count($queue) > $this->options['length']) {
                 // 出列
                 $key = array_shift($queue);
                 // 删除缓存
                 xcache_unset($key);
             }
             xcache_set('__info__', $queue);
         }
         return true;
     }
     return false;
 }
开发者ID:dingyi-History,项目名称:ime-daimaduan.cn,代码行数:36,代码来源:xcache.php

示例2: set

 /**
  * Set cache element
  *
  * This method will throw only logical exceptions.
  * In case of failures, it will return a boolean false.
  *
  * @param   string  $name    Name for cache element
  * @param   mixed   $data    Data to cache
  * @param   int     $ttl     Time to live
  *
  * @return  bool
  * @throws \Comodojo\Exception\CacheException
  */
 public function set($name, $data, $ttl = null)
 {
     if (empty($name)) {
         throw new CacheException("Name of object cannot be empty");
     }
     if (is_null($data)) {
         throw new CacheException("Object content cannot be null");
     }
     if (!$this->isEnabled()) {
         return false;
     }
     $this->resetErrorState();
     try {
         $this->setTtl($ttl);
         $shadowName = $this->getNamespace() . "-" . md5($name);
         $shadowTtl = $this->ttl;
         $shadowData = serialize($data);
         $return = xcache_set($shadowName, $shadowData, $shadowTtl);
         if ($return === false) {
             $this->raiseError("Error writing cache (XCache), exiting gracefully");
             $this->setErrorState();
         }
     } catch (CacheException $ce) {
         throw $ce;
     }
     return $return;
 }
开发者ID:comodojo,项目名称:cache,代码行数:40,代码来源:XCacheCache.php

示例3: set

 public function set($key, $value, $ttl = 0)
 {
     if ($ttl > 0) {
         return xcache_set($key, $value, $ttl);
     }
     return xcache_set($key, $value);
 }
开发者ID:locphp,项目名称:rsf,代码行数:7,代码来源:Xcache.php

示例4: set

 /**
  */
 public function set($key, $data, $lifetime = 0)
 {
     $key = $this->_params['prefix'] . $key;
     if (xcache_set($key . '_expire', time(), $lifetime)) {
         xcache_set($key, $data, $lifetime);
     }
 }
开发者ID:horde,项目名称:horde,代码行数:9,代码来源:Xcache.php

示例5: set

 public function set($key, $value, $expire = 86400)
 {
     if (!$key) {
         return false;
     }
     return xcache_set($key, $value, $expire);
 }
开发者ID:MrMoDoor,项目名称:Carbon-Forum,代码行数:7,代码来源:XCache.class.php

示例6: set

 public static function set($key, $value, $expires = false)
 {
     global $config;
     $key = $config['cache']['prefix'] . $key;
     if (!$expires) {
         $expires = $config['cache']['timeout'];
     }
     switch ($config['cache']['enabled']) {
         case 'memcached':
             if (!self::$cache) {
                 self::init();
             }
             self::$cache->set($key, $value, $expires);
             break;
         case 'apc':
             apc_store($key, $value, $expires);
             break;
         case 'xcache':
             xcache_set($key, $value, $expires);
             break;
         case 'php':
             self::$cache[$key] = $value;
             break;
     }
 }
开发者ID:niksfish,项目名称:Tinyboard,代码行数:25,代码来源:cache.php

示例7: set

 /**
  * Set a value based on an id. Optionally add tags.
  * 
  * @param   string   id 
  * @param   string   data 
  * @param   integer  lifetime [Optional]
  * @return  boolean
  */
 public function set($id, $data, $lifetime = NULL)
 {
     if (NULL === $lifetime) {
         $lifetime = Arr::get($this->_config, 'default_expire', Cache::DEFAULT_EXPIRE);
     }
     return xcache_set($this->_sanitize_id($id), $data, $lifetime);
 }
开发者ID:Tidwell,项目名称:HMXSongs-PHP-API,代码行数:15,代码来源:xcache.php

示例8: set

 /**
  * Set cache
  *
  * @param string $key
  * @param mixed $value
  * @param int $ttl
  * @return boolean
  */
 public function set($key, $value, $ttl = null)
 {
     if (null === $ttl) {
         $ttl = $this->options['ttl'];
     }
     return xcache_set($key, $value, $ttl);
 }
开发者ID:vzina,项目名称:yaf-api,代码行数:15,代码来源:Xcache.php

示例9: store

 public function store($key, $value)
 {
     if (xcache_set($key, $value)) {
         xcache_inc('__known_xcache_size', strlen($value));
     }
     return false;
 }
开发者ID:sensiblemn,项目名称:Known,代码行数:7,代码来源:XCache.php

示例10: set

 function set($key, $value, $ttl)
 {
     if (!ini_get('xcache.var_size')) {
         return;
     }
     @xcache_set($key, serialize($value), $ttl);
 }
开发者ID:pihizi,项目名称:qf,代码行数:7,代码来源:cache_xcache.php

示例11: get

 /**
  * Veriyi döndürür
  *
  * @param string $name
  * @return bool|mixed|string
  */
 public function get($name = '')
 {
     if (false === ($var = xcache_get($name))) {
         xcache_set($name, $var = parent::get($name));
     }
     return $var;
 }
开发者ID:AnonymPHP,项目名称:Anonym-Config,代码行数:13,代码来源:XcacheReposity.php

示例12: write

 /**
  * Write value(s) to the cache
  *
  * @param string $key The key to uniquely identify the cached item
  * @param mixed $data The value to be cached
  * @param null|string $expiry A strtotime() compatible cache time. If no expiry time is set,
  *        then the default cache expiration time set with the cache configuration will be used.
  * @return closure Function returning boolean `true` on successful write, `false` otherwise.
  */
 public function write($key, $data, $expiry = null)
 {
     $expiry = $expiry ?: $this->_config['expiry'];
     return function ($self, $params) use($expiry) {
         return xcache_set($params['key'], $params['data'], strtotime($expiry) - time());
     };
 }
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:16,代码来源:XCache.php

示例13: set

 public function set($id, $data, array $tags = NULL, $lifetime)
 {
     if (!empty($tags)) {
         Kohana::log('error', 'Cache: tags are unsupported by the Xcache driver');
     }
     return xcache_set($id, $data, $lifetime);
 }
开发者ID:momoim,项目名称:momo-api,代码行数:7,代码来源:Xcache.php

示例14: set

 /**
  *	Store value in cache
  *	@return mixed|FALSE
  *	@param $key string
  *	@param $val mixed
  *	@param $ttl int
  **/
 function set($key, $val, $ttl = 0)
 {
     $fw = Base::instance();
     if (!$this->dsn) {
         return TRUE;
     }
     $ndx = $this->prefix . '.' . $key;
     $time = microtime(TRUE);
     if ($cached = $this->exists($key)) {
         list($time, $ttl) = $cached;
     }
     $data = $fw->serialize(array($val, $time, $ttl));
     $parts = explode('=', $this->dsn, 2);
     switch ($parts[0]) {
         case 'apc':
         case 'apcu':
             return apc_store($ndx, $data, $ttl);
         case 'redis':
             return $this->ref->set($ndx, $data, array('ex' => $ttl));
         case 'memcache':
             return memcache_set($this->ref, $ndx, $data, 0, $ttl);
         case 'wincache':
             return wincache_ucache_set($ndx, $data, $ttl);
         case 'xcache':
             return xcache_set($ndx, $data, $ttl);
         case 'folder':
             return $fw->write($parts[1] . $ndx, $data);
     }
     return FALSE;
 }
开发者ID:eghojansu,项目名称:moe,代码行数:37,代码来源:Cache.php

示例15: set

 /**
  * @param string $key
  * @param mixed $value
  * @param integer $ttl
  * @return mixed
  */
 public function set($key, $value, $ttl = null)
 {
     $serialized = serialize($value);
     if (null === $ttl) {
         return xcache_set($key, $serialized);
     }
     return xcache_set($key, $serialized, $ttl);
 }
开发者ID:mactronique,项目名称:phpcache,代码行数:14,代码来源:XcacheDriver.php


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