Skip to content

Commit 3178a3b

Browse files
authored
Merge branch 'final' into final
2 parents 163bbc5 + da31c4e commit 3178a3b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/phpFastCache/Helper/Psr16Adapter.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ public function set($key, $value, $ttl = null)
7878
$cacheItem = $this->internalCacheInstance
7979
->getItem($key)
8080
->set($value);
81-
if (is_int($ttl) || $ttl instanceof \DateInterval) {
81+
if (is_int($ttl) && $ttl <= 0) {
82+
$cacheItem->expiresAt((new \DateTime('@0')));
83+
} elseif (is_int($ttl) || $ttl instanceof \DateInterval) {
8284
$cacheItem->expiresAfter($ttl);
8385
}
8486
return $this->internalCacheInstance->save($cacheItem);
@@ -142,7 +144,10 @@ public function setMultiple($values, $ttl = null)
142144
try {
143145
foreach ($values as $key => $value) {
144146
$cacheItem = $this->internalCacheInstance->getItem($key)->set($value);
145-
if ($ttl) {
147+
148+
if (is_int($ttl) && $ttl <= 0) {
149+
$cacheItem->expiresAt((new \DateTime('@0')));
150+
} elseif (is_int($ttl) || $ttl instanceof \DateInterval) {
146151
$cacheItem->expiresAfter($ttl);
147152
}
148153
$this->internalCacheInstance->saveDeferred($cacheItem);
@@ -181,4 +186,4 @@ public function has($key)
181186
throw new phpFastCacheSimpleCacheException($e->getMessage(), null, $e);
182187
}
183188
}
184-
}
189+
}

0 commit comments

Comments
 (0)