Skip to content
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

Provide own backend instead of using config #21

Closed
PonteIneptique opened this issue Feb 17, 2017 · 2 comments
Closed

Provide own backend instead of using config #21

PonteIneptique opened this issue Feb 17, 2017 · 2 comments

Comments

@PonteIneptique
Copy link
Contributor

Hi there, it's me again.
One thing I'd like to do is to be able to provide my own backend object instead of going through config with a keyword argument backend on __init__(). This way I can share or have specific backend objects across my code base :)

If this feature is okay, I'll put in the work. Question is : would type checking be required for werkzeug.contrib.BaseCache ?

Cheers

@sh4nks
Copy link
Collaborator

sh4nks commented Mar 4, 2017

Couldn't you just instantiate another instance with a different backend?

Question is : would type checking be required for werkzeug.contrib.BaseCache ?

I am not sure if I understand you correctly..
Do you mean if you have to subclass BaseCache?

@sh4nks sh4nks closed this as completed Jun 23, 2017
@sh4nks sh4nks reopened this Jun 23, 2017
@sh4nks
Copy link
Collaborator

sh4nks commented Jun 25, 2017

https://pythonhosted.org/Flask-Caching/#custom-cache-backends

You are able to easily add your own custom cache backends by exposing a function that can instantiate and return a cache object. CACHE_TYPE will be the import string to your custom function. It should expect to receive three arguments.

  • app
  • args
  • kwargs

Your custom cache object must also subclass the werkzeug.contrib.cache.BaseCache class. Flask-Caching will make sure that threshold is already included in the kwargs options dictionary since it is common to all BaseCache classes.

@sh4nks sh4nks closed this as completed Jun 25, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants