本文整理汇总了PHP中Illuminate\Cache\Repository::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::add方法的具体用法?PHP Repository::add怎么用?PHP Repository::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Cache\Repository
的用法示例。
在下文中一共展示了Repository::add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShouldReturnNullFlushRecord
public function testShouldReturnNullFlushRecord()
{
$this->repository->add('memcached-testing', 'couchbase', 60);
$this->repository->decrement('memcached-testing-decrement', 100);
$this->repository->increment('memcached-testing-increment', 100);
$this->repository->flush();
$this->assertNull($this->repository->get('memcached-testing'));
$this->assertNull($this->repository->get('memcached-testing-decrement'));
$this->assertNull($this->repository->get('memcached-testing-increment'));
}
示例2: save
/**
* {@inheritdoc}
*/
public function save($key, CacheEntry $data)
{
try {
$lifeTime = $data->getTTL();
if ($lifeTime === 0) {
return $this->cache->forever($key, serialize($data));
} else {
if ($lifeTime > 0) {
return $this->cache->add($key, serialize($data), $lifeTime);
}
}
} catch (\Exception $ignored) {
// No fail if we can't save it the storage
}
return false;
}
示例3: returnResults
/**
* Return result values
*
* @param array $results
* @param string $key
*
* @return string|array
*/
protected function returnResults($results, $key)
{
if ($results && count($results) > 1) {
$results = $this->arrangeResults($results, $key);
$this->cache->add($this->attachTag($key), $results, $this->expiry);
return $results;
}
if ($results) {
$result = @json_decode($results[$key]) ?: $results[$key];
$this->cache->add($this->attachTag($key), $result, $this->expiry);
return $result;
}
}
示例4: add
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return bool
* @static
*/
public static function add($key, $value, $minutes)
{
return \Illuminate\Cache\Repository::add($key, $value, $minutes);
}
示例5: add
/**
* Store an item in the cache if the key does not exist.
*
* @param mixed $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return mixed
*/
public function add($key, $value, $minutes)
{
if (is_array($key) && is_array($value)) {
return $this->addMany(array_combine($key, $value), $minutes);
}
return parent::add($key, $value, $minutes);
}
示例6: add
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
* @return bool
* @throws \Propaganistas\LaravelCacheKeywords\Exceptions\ReservedCacheKeyPatternException
*/
public function add($key, $value, $minutes)
{
$this->checkReservedKeyPattern($key);
$this->setKeywordsOperation(true);
if ($result = parent::add($key, $value, $minutes)) {
$this->storeKeywords($key, $minutes, $this->keywords);
}
$this->setKeywordsOperation(false);
$this->resetCurrentKeywords();
return $result;
}
示例7: add
/**
* Store an item in the cache if the key does not exist.
*
* @param string $key
* @param mixed $value
* @param \DateTime|int $minutes
*
* @return bool
*/
public function add($key, $value, $minutes)
{
return $this->enabled ? $this->cache->add($key, $value, $minutes) : false;
}
示例8: setItem
/**
* Set cache entry
*
* @param string $key
* @param string $content
*
* @return void
*/
public function setItem($key, $content)
{
$key = $this->getKey($key);
$ttl = $this->configurationRepository->get('shariff.cache.ttl');
$this->cacheRepository->add($key, $content, $ttl);
}