-
Notifications
You must be signed in to change notification settings - Fork 53
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
feature request: extend redis backend #63
Comments
Great idea! I'll have to think a bit on it, but I'll get back to you on this! edit: the implementation you suggest cannot be used as-is, because what SlackMachine does by default, is prefixing keys in Redis with a unique identifier for each plugin. This should be taken into account when scanning. The pattern provided through the |
That's fine. I assume that you mean something along the lines of this: def keys(self, key):
return self._redis.scan_iter(pattern='{}:*'.format(self._prefix(key)))
... I'm adding the following right underneath http://slack-machine.readthedocs.io/en/latest/_modules/machine/storage/backends/base.html#MachineBaseStorage.get: def keys(self, key, shared=False):
"""Retrieve data by key
:param key: key for the data to retrieve
:param shared: ``True/False`` wether to retrieve data from the shared (global) namespace.
:return: the data, or ``None`` if the key cannot be found/has expired
"""
namespaced_key = self._namespace_key(key, shared)
# value = Storage.get_instance().get(namespaced_key)
value = Storage.get_instance().keys(namespaced_key)
if value:
return dill.loads(value)
else:
return None But, I'm still getting the error:
Is there something else I'm missing? It's fine if this method could be renamed to "get_all_keys", or something of the sort. I'd like to extend the functionality of the storage backend to support more (or all) redis-py functions, if possible. After modifying these files, do I just run |
Let's extend the redis backend to support more actions like:
This would be in order to scan or get all keys for a given plugin and iterate over them.
I'm trying to create a "Karma" plugin and I'd like to show the top Karma scores:
in
machine/storage/backends/redis.py
:Something like this...
But, I get:
AttributeError: 'PluginStorage' object has no attribute 'keys'
The text was updated successfully, but these errors were encountered: