Skip to content

Commit fb1cd5e

Browse files
committed
Attempting to fix random-falling apcu test
1 parent 18b4851 commit fb1cd5e

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

lib/Phpfastcache/Drivers/Apcu/Driver.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ protected function driverWrite(CacheItemInterface $item): bool
7676
* Check for Cross-Driver type confusion
7777
*/
7878
if ($item instanceof Item) {
79-
$ttl = $item->getExpirationDate()->getTimestamp() - time();
80-
81-
return (bool)apcu_store($item->getKey(), $this->driverPreWrap($item), ($ttl > 0 ? $ttl : 0));
79+
return (bool) apcu_store($item->getKey(), $this->driverPreWrap($item), $item->getTtl());
8280
}
8381

8482
throw new PhpfastcacheInvalidArgumentException('Cross-Driver type confusion detected');

lib/Phpfastcache/Helper/TestHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ public function runCRUDTests(ExtendedCacheItemPoolInterface $pool)
369369
$this->printInfoText('Running CRUD tests on the following backend: ' . get_class($pool));
370370
$pool->clear();
371371

372-
$cacheKey = 'cache_key_' . bin2hex(random_bytes(12) . '_' . random_int(100, 999));
372+
$cacheKey = 'cache_key_' . bin2hex(random_bytes(8) . '_' . random_int(100, 999));
373373
$cacheValue = 'cache_data_' . random_int(1000, 999999);
374-
$cacheTag = 'cache_tag_' . bin2hex(random_bytes(12) . '_' . random_int(100, 999));
374+
$cacheTag = 'cache_tag_' . bin2hex(random_bytes(8) . '_' . random_int(100, 999));
375375
$cacheItem = $pool->getItem($cacheKey);
376376
$this->printInfoText('Using cache key: ' . $cacheKey);
377377

0 commit comments

Comments
 (0)