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

Add support for key prefixes #607

Open
willroberts opened this issue Jul 27, 2017 · 16 comments
Open

Add support for key prefixes #607

willroberts opened this issue Jul 27, 2017 · 16 comments

Comments

@willroberts
Copy link

Reviving this issue: #563

SELECT doesn't work with clustered Redis, so it's not an appropriate replacement for key prefixing in that case.

@wybosys
Copy link

wybosys commented Dec 28, 2018

prefix is needed if multi project use a same redis-server

@ljnszu
Copy link

ljnszu commented May 8, 2020

also need

@wziww
Copy link
Contributor

wziww commented May 8, 2020

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))

@goxiaoy
Copy link

goxiaoy commented Nov 29, 2020

This would be useful for multi tenancy application too

@mengdodo
Copy link

+10086

@andbridge
Copy link

need

@Sitrone
Copy link

Sitrone commented Jun 28, 2021

it would be useful for multi micro service, when they are use the same redis cluster too

@joewongex
Copy link

need

@logyball
Copy link

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.

@joewongex
Copy link

joewongex commented Mar 15, 2022 via email

@ruanlianjun
Copy link

we need it

@florian-besser
Copy link

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

@richelieu-yang
Copy link

need

@realpg
Copy link

realpg commented Nov 13, 2023

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...

@joewongex
Copy link

joewongex commented Nov 13, 2023 via email

@heffcodex
Copy link

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.

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

No branches or pull requests