Giter Site home page Giter Site logo

Comments (2)

DonDebonair avatar DonDebonair commented on May 22, 2024

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 keys(...) method could be prefixed with the unique idea for example.

from slack-machine.

cabrinha avatar cabrinha commented on May 22, 2024

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:

AttributeError: 'PluginStorage' object has no attribute 'keys'

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 python3 setup.py install again?

from slack-machine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.