go-redis
go-redis copied to clipboard
Add support for key prefixes
Reviving this issue: https://github.com/go-redis/redis/issues/563
SELECT
doesn't work with clustered Redis, so it's not an appropriate replacement for key prefixing in that case.
prefix is needed if multi project use a same redis-server
also need
I do think this should be done in your application level, not in basic redis client level Such as create an function like this
var (
prefix string = "AAA_"
)
func Key(s string)string{
return prefix + s
}
// then
redisClient.Get(Key(xxx))
This would be useful for multi tenancy application too
+10086
need
it would be useful for multi micro service, when they are use the same redis cluster too
need
This would also be excellent for my use case! When using non-clustered redis, it is trivial to switch between logical databases. However, clustered redis makes it difficult for multi-tenancy within the same redis instance, which would be excellent to implement at the client level rather than in application code.
你好,你的邮件我已收到
we need it
We just ran into this as well; the redis client should support selecting a key prefix.
Another reason why redis databases are not cutting it (other than them being deprecated) is around ACL. I can define multiple users in my redis cluster and provide different access e.g. by using an access string like on ~TENANT_NAME:* &* -@all +@connection +@read +@write
This allows me to have multiple users on the same redis instance with separated access rights.
Other redis clients, e.g. https://www.npmjs.com/package/ioredis are implementing this feature as well
need
I do think this should be done in your application level, not in basic redis client level Such as create an function like this
var ( prefix string = "AAA_" ) func Key(s string)string{ return prefix + s } // then redisClient.Get(Key(xxx))
your own code works well. BUT when you use a library, which use go-redis, you cannot change the library code...
你好,你的邮件我已收到
Absolutely needed. There is a common practice to use the same redis cluster around multiple microservices. Especially we had to make a wrapper to use key prefixes as "namespaces", but now it requires additional work for keeping the wrapper up to date with redis library and generally looks weird in usage as it still also needs some user-land code that constructs the key and then passes it to redis client methods.