本文整理匯總了PHP中Psr\Cache\CacheItemInterface::getExpirationDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP CacheItemInterface::getExpirationDate方法的具體用法?PHP CacheItemInterface::getExpirationDate怎麽用?PHP CacheItemInterface::getExpirationDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Cache\CacheItemInterface
的用法示例。
在下文中一共展示了CacheItemInterface::getExpirationDate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: driverWrite
/**
* @param \Psr\Cache\CacheItemInterface $item
* @return mixed
* @throws \InvalidArgumentException
*/
protected function driverWrite(CacheItemInterface $item)
{
/**
* Check for Cross-Driver type confusion
*/
if ($item instanceof Item) {
$ttl = $item->getExpirationDate()->getTimestamp() - time();
return zend_shm_cache_store($item->getKey(), $this->driverPreWrap($item), $ttl > 0 ? $ttl : 0);
} else {
throw new \InvalidArgumentException('Cross-Driver type confusion detected');
}
}
示例2: save
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$timeToLive = 0;
if ($item instanceof HasExpirationDateInterface) {
if (null !== ($expirationDate = $item->getExpirationDate())) {
$timeToLive = $expirationDate->getTimestamp() - time();
}
}
return $this->cache->save($item->getKey(), $item, $timeToLive);
}
示例3: save
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
if ($item instanceof TaggableItemInterface) {
$key = $item->getTaggedKey();
} else {
$key = $item->getKey();
}
$timeToLive = null;
if ($item instanceof HasExpirationDateInterface) {
if (null !== ($expirationDate = $item->getExpirationDate())) {
$timeToLive = $expirationDate->getTimestamp() - time();
}
}
return $this->storeItemInCache($key, $item, $timeToLive);
}
示例4: save
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$data = "{$item->get()};{$item->getExpirationDate()->format('Y-m-d H:i:s')}";
file_put_contents("{$this->cacheFolder}/{$item->getKey()}.txt", $data);
return true;
}
示例5: save
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$timeToLive = null;
if ($item instanceof HasExpirationDateInterface) {
if (null !== ($expirationDate = $item->getExpirationDate())) {
$timeToLive = $expirationDate->getTimestamp() - time();
if ($timeToLive < 0) {
return $this->deleteItem($item->getKey());
}
}
}
try {
return $this->storeItemInCache($item, $timeToLive);
} catch (\Exception $e) {
$this->handleException($e, __FUNCTION__);
}
}
示例6: save
/**
* @param CacheItem $item
* {@inheritDoc}
*/
public function save(CacheItemInterface $item)
{
return $this->cache->save($item->getKey(), ['value' => $item->get(), 'expiration' => $item->getExpirationDate()]);
}