Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Add key prefix option for cache #227

Closed
leplatrem opened this issue Apr 15, 2015 · 4 comments
Closed

Add key prefix option for cache #227

leplatrem opened this issue Apr 15, 2015 · 4 comments

Comments

@leplatrem
Copy link
Contributor

  • Add a setting cliquet.cache_prefix (default: '')
  • Every cache entry key is prefixed by self.prefix in cache backend classes
@lavish205
Copy link
Contributor

I want to work on this bug, looking forward for instructions to start.

@leplatrem
Copy link
Contributor Author

When a key is passed to a method of the cache backend (e.g. here), it should be concatenated to a prefix coming from the settings.

That means the key prefix should be passed to the constructor of cache backend (e.g. here)

@lavish205
Copy link
Contributor

I have few doubts

  • In which file we are supposed to add a setting cliquet.cache_prefix (default: '')
  • What is self.prefix exactly here? I can't see any variable named prefix in CacheBase class.
  • And if it is supposed to passed to constructor here, then what will be the value of key prefix?

@leplatrem
Copy link
Contributor Author

I will try to answer your questions:

In which file we are supposed to add a setting

in cliquet/__init__.py, you define the default settings values.

What is self.prefix exactly here?

This is value received from the constructor of the Cache backend. It does not exist yet and should be added.
It will be used in the cache backend to concatenate with the key passed in arguments of each method.

what will be the value of key prefix ?

in the load_from_config function, you obtain the setting from the config object:

settings = config.get_settings()
prefix = settings['cache_prefix']
backend = Cache(prefix=prefix)
return backend

Hope this helps ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants