You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, werkzeug.contrib.cache.RedisCache.clear should return a boolean value to indicate Whether the cache has been cleared.
However, because self._client.delete(*keys) returns an integer as the number of keys removed, the actual returned value could be an integer. And since clear is not atomic, the returned number may be not equal to the len(keys).
Maybe we could set status according to existence of redis.exceptions.ResponseError?
For example:
BTW, if there is nothing to clear, RedisCache.clear will return False. On the same occasion, FileSystemCache.clear will return True. The documentation about this occasion is not clear.
I could submit a patch if those behaviors are considered as bug.
The text was updated successfully, but these errors were encountered:
One more thing, RedisCache.clear should not use keys to get all keys.
Use keys in production is not recommended. Some people even suggest to rename keys command in production environment. I observed the mistake in a PHP background task before. The keys operation locked the Redis for more than 1 second, caused a great number of redis operation timeouts. I am not willing to see this happens again.
There is already an issue about replacing keys with scan(#1069), but there is not a related pull request yet.
I am using python 2.7.12 with :
According to the documentation,
werkzeug.contrib.cache.RedisCache.clear
should return a boolean value to indicateWhether the cache has been cleared
.However, because
self._client.delete(*keys)
returns an integer as the number of keys removed, the actual returned value could be an integer. And sinceclear
is not atomic, the returned number may be not equal to thelen(keys)
.Maybe we could set
status
according to existence ofredis.exceptions.ResponseError
?For example:
BTW, if there is nothing to clear, RedisCache.clear will return False. On the same occasion, FileSystemCache.clear will return True. The documentation about this occasion is not clear.
I could submit a patch if those behaviors are considered as bug.
The text was updated successfully, but these errors were encountered: