Skip to content

Commit 684b30e

Browse files
committed
has uses get to expire old transients
Fixes #4
1 parent ef216f1 commit 684b30e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/CachePool.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ public function deleteMultiple($keys)
191191
public function has($key)
192192
{
193193
$default = $this->defaultValue;
194-
$prefix = $this->getOptionNamePrefix();
195-
$value = $this->getOption("{$prefix}{$key}", $default);
194+
$value = $this->get($key, $default);
196195

197196
return $value !== $default;
198197
}

tests/functional/CachePoolTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,18 +313,16 @@ public function testHas()
313313
$defaultValue = uniqid('default');
314314
$wpdb = $this->createWpdb();
315315
$key = uniqid('key');
316-
$separator = TestSubject::NAMESPACE_SEPARATOR;
317-
$transientName = "{$poolName}{$separator}{$key}";
318-
$optionName = "_transient_$transientName";
319316
$notThereKey = uniqid('not-there');
320-
$notThereTransientName = "{$poolName}{$separator}{$notThereKey}";
321-
$notThereOptionName = "_transient_$notThereTransientName";
322-
$subject = $this->createInstance($wpdb, $poolName,$defaultValue );
317+
$subject = $this->createInstance($wpdb, $poolName, $defaultValue);
323318
}
324319

325320
{
321+
Functions\expect('get_transient')
322+
->andReturnValues([uniqid('value'), false]);
323+
326324
Functions\expect('get_option')
327-
->andReturnValues([uniqid('value'), $defaultValue]);
325+
->andReturnValues([$defaultValue]);
328326
}
329327

330328
{

0 commit comments

Comments
 (0)