-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add ability to prefix keys #11
Comments
@ajbrown is there a reason you're not using a different database within the same redis instance to hold the other application's info? That should be the cleanest way to ensure there is no cross pollution of keys (and also gives you the ability to switch that app off easily to a new redis instance if things get hot on one app. Are there some queries that are hitting both sets of keys (maybe set comparison or something)? I worry about the usability implications of this (and how you'd decide when you'd want to override it that you really don't want the prefix for some queries). How I've dealt with this kind of thing in the past with things in the same db instance is to just have a string key factory that I use to generate my keys rather than just building them up in place. It can be as simple as a static import:
You have one of those for each of your apps, then in your classes where you're calling redis, you just:
As you say, you do then still need to be careful that all keys are actually using the key factory rather than If that doesn't work, what would the semantics be if you didn't want to use the prefix for some particular command? One thing that comes to mind is actually leveraging the new redis pooling stuff that's in grails redis 1.3 to also include prefix as part of the config information for a particular connection (and allowing multiple connections). If a prefix is defined on a connection associated with a service, all calls with that service use the prefix. To not have the prefix added, you'd just define another connection to the same instance without the prefix and inject that instead into the services that might need it. |
Hey @tednaleid, We actually do use a string factory like you suggested, but we don't include the prefix. After thinking twice about your response, I'm beginning to believe you're correct in that this is better addressed in our implementation than in the plugin. Unless anyone else has some input, I'm going to close this issue. |
It would be very useful to allow specifying an application-wide prefix for all keys. We currently have two applications which are sharing the same redis server. We are managing to avoid collisions by being careful about our key selection, but a much better solution would be a configurable prefix in Config.groovy.
The text was updated successfully, but these errors were encountered: