bbangert / beaker

WSGI middleware for sessions and caching
https://beaker.readthedocs.org/
Other
517 stars 146 forks source link

Redis key prefix should be configurable #177

Open multani opened 5 years ago

multani commented 5 years ago

Currently, the RedisNamespaceManager prefixes all the keys with beaker_cache:.

This should be a configurable parameter of the namespace manager, that would allow to use different instances of Beaker with different applications, without having to specify different databases. This may also help to distinguish "owners" of the keys, as instead of having beaker_cache has a prefix, it would be possible to put a more "application friendly" name.

If not specified, the default value should stay with beaker_cache.

multani commented 5 years ago

If this feature is willing to be accepted, I'd be glad to propose a pull request to support that use case :+1:

amol- commented 5 years ago

Is the purpose of this to allow multiple applications with same namespace and same key to store in the same redis? I'm only concerned about consistency with the other namespace managers. Most of them don't allow to configure the prefix as it's an internal implementation detail.

multani commented 5 years ago

@amol- Basically, yes the purpose is to have different applications using Beaker and the same namespaces/keys without conflicting with each other.

We also have a "monitoring" aspects, in the sense that we have some scripts running which are computing resource usage based on this initial prefix. We have other frameworks/languages using Redis and we configured them to store the "application name" (or something equivalent) as the initial key prefix ... which works well for our use cases, except for our Python applications which are all grouped under the same prefix. (I know it's probably better to use different Redis servers/databases to separate application concerns, but that may not be always possible for various reasons).

As for your concern regarding the other managers, I don't see it as a particular problem: