| @@ 69-89 (lines=21) @@ | ||
| 66 | * @return mixed |
|
| 67 | * @throws phpFastCacheInvalidArgumentException |
|
| 68 | */ |
|
| 69 | protected function driverWrite(CacheItemInterface $item) |
|
| 70 | { |
|
| 71 | /** |
|
| 72 | * Check for Cross-Driver type confusion |
|
| 73 | */ |
|
| 74 | if ($item instanceof Item) { |
|
| 75 | $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
| 76 | ||
| 77 | /** |
|
| 78 | * @see https://redis.io/commands/setex |
|
| 79 | * @see https://redis.io/commands/expire |
|
| 80 | */ |
|
| 81 | if($ttl <= 0){ |
|
| 82 | return $this->instance->expire($item->getKey(), 0); |
|
| 83 | }else{ |
|
| 84 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
|
| 85 | } |
|
| 86 | } else { |
|
| 87 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * @param \Psr\Cache\CacheItemInterface $item |
|
| @@ 65-85 (lines=21) @@ | ||
| 62 | * @return mixed |
|
| 63 | * @throws phpFastCacheInvalidArgumentException |
|
| 64 | */ |
|
| 65 | protected function driverWrite(CacheItemInterface $item) |
|
| 66 | { |
|
| 67 | /** |
|
| 68 | * Check for Cross-Driver type confusion |
|
| 69 | */ |
|
| 70 | if ($item instanceof Item) { |
|
| 71 | $ttl = $item->getExpirationDate()->getTimestamp() - time(); |
|
| 72 | ||
| 73 | /** |
|
| 74 | * @see https://redis.io/commands/setex |
|
| 75 | * @see https://redis.io/commands/expire |
|
| 76 | */ |
|
| 77 | if($ttl <= 0){ |
|
| 78 | return $this->instance->expire($item->getKey(), 0); |
|
| 79 | }else{ |
|
| 80 | return $this->instance->setex($item->getKey(), $ttl, $this->encode($this->driverPreWrap($item))); |
|
| 81 | } |
|
| 82 | } else { |
|
| 83 | throw new phpFastCacheInvalidArgumentException('Cross-Driver type confusion detected'); |
|
| 84 | } |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * @param \Psr\Cache\CacheItemInterface $item |
|