本文整理汇总了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()]);
}