I've got a function which returns a dict with some values. the function has this decorator:
@cache('admin.setting.limits', 3600, cache.ram)
def get_limits():
..This works fine and the values are used from cache. When I change those settings I want to clear the cache so I'm doing this:
cache.ram.clear(regex='admin\.setting.*')
When I call my function again the cached values are still used. Am I doing something wrong here? Any ideas?
regards,
Alex
tested with clearing values with exact key and this seems to work. Do you know why using the regex doesn't work?
Alex
the regex should be fine (I tested it with a regex online tool). Doesn't make a difference if I use your regex.
Thanks for your help, I can fix the problem by clearing the exact values. But I'd still like to understand what's wrong with clearing the cache by regex.
cache.ram.clear(regex=r'admin\.setting.*')
That would make sense. But it's still the same result. I've changed my cache keys to avoid dots and only use underscore instead:
adminsetting_limits
and now I can delete the cached values without any problems:
cache.ram.clear(regex=r'adminsetting.*')
I still don't fully understand why the original regex doesn't work but at least it's not an issue anymore.
r = re.compile(regex)
for (key, value) in storage.items():
if r.match(str(key)):
del storage[key]
r = re.compile(regex)
for key in storage:
if r.match(str(key)):
del storage[key]
break
I will fix it later today
exactly, that's the issue. Now it makes sense why it worked on very rare occasions. A test for this use case would be a good idea. here is the code in 2.4.6 which runs fine:r = re.compile(regex)
for (key, value) in storage.items():
if r.match(str(key)):
del storage[key]
and this is the code from 2.9.11 which fails:r = re.compile(regex)
for key in storage:
if r.match(str(key)):
del storage[key]
break
should I open a bug report or can someone directly fix it?
Alex--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/72vUKgyDkxQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.