Code Monkey home page Code Monkey logo

Comments (3)

emilhe avatar emilhe commented on June 14, 2024 1

I have added an (experimental) implementation in version 0.0.53, and it seems to work. The only pitfall that i am aware of is that the Dash app will crash if a (k,v) pair expires in the Redis cache. Hence you should either set the timeout to 0 (inf), or at least higher that you would ever expect a user to be connected to your app. Let me know how it goes :)

app = DashProxy(transforms=[ServersideOutputTransform(backend=RedisStore())])

from dash-extensions.

slochower avatar slochower commented on June 14, 2024 1

Sweet! This appears to be working flawlessly. I simply changed the FileSystemStore to RedisStore and didn't make any other changes.

from dash-extensions.

slochower avatar slochower commented on June 14, 2024

Edit: After reading all the way to your most recent post (oops), would it be conceivable to add a class along these lines?

from flask_caching import RedisCache

class RedisStore(RedisCache):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def get(self, key, ignore_expired=False):
        if not ignore_expired:
            return super().get(key)

        # Is there an analog of `_get_filename` for RedisCache?

        # TODO: This part must be implemented for each type of cache.
        # filename = self._get_filename(key)
        # try:
        #     with open(filename, "rb") as f:
        #         pickle_time = pickle.load(f)  # ignore time
        #         return pickle.load(f)
        # except (IOError, OSError, pickle.PickleError):
        #     return None

...where RedisStore could take an already defined flask cache, like RedisCache(cache) or keyword arguments for host, password, etc.

If so, I'd be happy to try a PR.

from dash-extensions.

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.