Stash icon indicating copy to clipboard operation
Stash copied to clipboard

save() than isMiss() -> true

Open IAkumaI opened this issue 8 years ago • 4 comments

$key = md5(microtime(true));

$cache = $pool->getItem($key);
$cache->set('Test value');
$cache->save();

if ($cache->isMiss()) {
    echo 'Missed', PHP_EOL;
}

echo 'Value: ', $cache->get(), PHP_EOL;

No matter what driver is used. It always will be Missed. Because of after save() isMiss method do not call excuteGet() because of $this->data of Item is filled.

The solution is get new Item before check isMiss().

IAkumaI avatar Aug 30 '16 12:08 IAkumaI

Having a similar issue, item will not return true after saving and running "isHit()". Looking at the source, it does appear to be the aforementioned case. Will do a quick test and create a pull request.

Unrealomega avatar Oct 15 '16 09:10 Unrealomega

So, what I can see on my end, apparently the miss is occurring due to Expiration not being set. This looks to be due to how Interval deals with seconds, as anything above 3599 seconds will be ignored when it's added/substracted, suspect this is due to how Interval deals with time. Looking at making a fix for that now.

Unrealomega avatar Oct 15 '16 11:10 Unrealomega

Made an update to my fork, though now I'm seeing issues with it storing the expiration date of the item, which I'm not sure why (Switch from Redis to Ephemeral to no affect). For now, I give up on this and will just look at other options than Stash.

Unrealomega avatar Oct 15 '16 17:10 Unrealomega

Is this still a bug in the system?

alexbowers avatar Feb 28 '17 11:02 alexbowers