主要针对数据量大页面流量高的环境做的缓存策略,数据会进行切片缓存处理并使用延时队列保证数据在阶段时间内的数据更新。
- PHP >= 7.0.0
- Laravel >= 5.5.0
- Redis
<?php
CacheToolFunc::instance()->inputParams($params)
->callStaticFunc(CacheFunc::class, 'getData')
->setMaxSliceSize(40)
->setTemplate([
'id' => '_id',
...
])
->setTTl(120)
->keepTime(2)
->output();
CacheToolFunc::instance()->inputParams($params);
CacheToolFunc::instance()->callStaticFunc($class, $method);
CacheToolFunc::instance()->callFunc($class, $method);
CacheToolFunc::instance()->setMaxSliceSize($sliceSize);
CacheToolFunc::instance()->setTemplate([
'id' => 'doc_id',
'name' => 'project_name'
]);
CacheToolFunc::instance()->setTTl(60);
CacheToolFunc::instance()->keepTime(60);
CacheToolFunc::instance()->setConnection('default');
CacheToolFunc::instance()->flush();
CacheToolFunc::instance()->setSuffix('key');
<?php
RedisCache::getInstance($this->select, $this->connection)
->pipeline()
->pushSliceData($this->backInfo, $this->suffixKey, $this->maxSliceSize, $this->cacheModule, $this->ttl, $this->ttlIsRandom)
->exec();
<?php
RedisCache::getInstance(0, $this->connection)
->pipeline()
->popSliceData($this->suffixKey, $this->maxSliceSize, $this->cacheModule)
->exec();