Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis clear method #207

Closed
ivanskins opened this issue Jan 28, 2015 · 9 comments
Closed

Redis clear method #207

ivanskins opened this issue Jan 28, 2015 · 9 comments

Comments

@ivanskins
Copy link

I save cache in Redis with this code:

$item = $pool->getItem('34', 'templates', 'page1');
$data = $item->get();
if($item->isMiss()) {
...
}
$item->set($data);

But then I execute:
$pool->getItem('34', 'templates')->clear();

And NO clearing was executed, may be I do simething wrong?

@Nakard
Copy link

Nakard commented Jan 28, 2015

What do you mean exactly by "no clearing executed"? Does

$pool->getItem('34', 'templates', 'page1')->isMiss()

return false after using clear()?

Or do you mean that there is still something on the Redis server? If that's the problem, then look at this issue

@ivanskins
Copy link
Author

Sorry ... "no clearing executed" means that key "34/templates/page1" was not deleted from Redis

@tedivm
Copy link
Member

tedivm commented Mar 9, 2015

So if you retrieve ""34/templates/page1" again you get the value back and isMiss returns false, even though you cleared it? Can you show me a full script executing this?

@ivanskins
Copy link
Author

the problem is not in isMiss method. The problem is in the following:

  1. I created cache "34/templates/page1"
  2. I created cache "34/templates/page2"
  3. I want to clear all children of "34/templates"
  4. I call "$pool->getItem('34', 'templates')->clear();"
  5. BUT "34/templates/page1" and "34/templates/page2" are exist and were not deleted

@tedivm
Copy link
Member

tedivm commented Mar 9, 2015

Can you please answer my question? If you attempt to retrieve "34/templates/page1" and "34/templates/page2" from the caching system after clearing them what happens?

@ivanskins
Copy link
Author

I will try at the moment, one minute)

@ivanskins
Copy link
Author

Yes, result of "var_dump($item->isMiss())" is "true", it's correct.
But why the key exists in Redis? I think that key removing from Redis is a good idea.

@tedivm
Copy link
Member

tedivm commented Jul 7, 2015

Sorry to disappear from the conversation.

In order to get hierarchal caching to work Stash uses an index system that relies on numbered keys. When things are purged those keys are incremented and the stale items get orphaned. The downside to this method is that it isn't easy to clear those purged items from inside Stash itself, but the two systems we do this with (Redis and Memcache) will handle that automatically using the "Least Recently Used" expiration method.

@tedivm
Copy link
Member

tedivm commented Dec 16, 2015

Closing this out as it's expected behavior.

@tedivm tedivm closed this as completed Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants