每天laravel-20160620|MemcachedConnector
来源:互联网 发布:nginx需要密码访问 编辑:程序博客网 时间:2024/06/05 02:37
namespace Illuminate\Cache;
use Memcached;
use Illuminate\Contracts\Cache\Store;
// a namespace about the user
class MemcachedStore extends TaggableStore implements Store
{// a Store about Memcache Store
/**
* The Memcached instance.
* The Memcached instance.
* @var \Memcached
*/
protected $memcached;
/** * A string that should be prepended to keys. * A string that should be prepended to keys. * @var string */protected $prefix;// a string about the prefix. with connection about the/** * Create a new Memcached store. * Create a new Memcached store. * @param \Memcached $memcached * @param string $prefix * @return void */public function __construct($memcached, $prefix = ''){ $this->setPrefix($prefix); $this->memcached = $memcached;}// a supper big prefix/** * Retrieve an item from the cache by key. * Retrieve an item form the cache by key. * @param string|array $key * @return mixed */public function get($key){ $value = $this->memcached->get($this->prefix.$key);// a way to get value if ($this->memcached->getResultCode() == 0) { return $value; }// if return value,}// get a method/** * Retrieve multiple items from the cache by key. * Retrieve multiple items from the cache by key. * * Items not found in the cache will have a null value. * Items not found in the cache will have a null value. * @param array $keys * @return array */public function many(array $keys){ $prefixedKeys = array_map(function ($key) { return $this->prefix.$key; }, $keys);// you are master , $values = $this->memcached->getMulti($prefixedKeys, null, Memcached::GET_PRESERVE_ORDER); // more get if ($this->memcached->getResultCode() != 0) { return array_fill_keys($keys, null); }// get the result return array_combine($keys, $values);}// get a lot of keys
0 0
- 每天laravel-20160620|MemcachedConnector
- 每天laravel
- 每天laravel-20160622|MeacachedStore
- 每天laravel-20160623|NullStore
- 每天laravel-20160624|RateLimiter
- 每天laravel-20160625|RedisStore
- 每天laravel-20160626|RetrievesMultipleKeys
- 每天laravel-20160627|TaggableStore
- 每天laravel-20160628|TaggedCache
- 每天laravel-20160629|RedisTaggedCache
- 每天laravel-20160701|Repository
- 每天laravel-20160702|CacheTableCommand
- 每天laravel-20160703|ClearCommand
- 每天laravel-20160704|CahceHit
- 每天laravel-20160705|CahceMissed
- 每天laravel-20160706|KeyForgotten
- 每天laravel-20160707|KeyWritten
- 每天laravel-20160708|Repository
- Maximum Depth of Binary Tree
- android基本架构
- 感悟:Java的多线程跟Java的类系统之间的关系
- 01背包问题
- java 多线程--概要
- 每天laravel-20160620|MemcachedConnector
- 码农小汪-剑指Offer之12 -链表中倒数第k个结点
- python学习的一些小技巧小结
- C# 全局变量与局部变量
- mysql Source导入问题
- iOS 不同颜色之分段式圆环,段数不固定
- 通过AndroidTestCase来进行android 单元测试 part II
- android5.1+获取当前运行的app2
- 数据探索之缺失值处理及代码实现