There are two popular stones for adding a namespace in redis: redis-namespace and Nest , if I really understand that we need a namespace when we use the same redis instance server with different projects, if I'm right, that means: if I have there is project-1 and project-2, and each of these projects uses my local redis repository, then maybe two projects have a user key that represents the users of my application, so to prevent a conflict, I need to proxy the user key with something- something like and Yeni project:
for project 1:
project-1:users
for project-1
project-2:users
if my understanding is not correct above, we can use the redis-namespace gem to solve this problem as follows:
r = Redis::Namespace.new(:project-1, :redis => @r) r['users']['joe']['email'] = ' joe@example.com '
and for the second project (project-2), you just need to change project-1 to project-2 when creating a new Redis :: Namespace:
r = Redis::Namespace.new(:project-2, :redis => @r) r['users']['joe']['email'] = ' joe@example.com '
please tell me if I am not mistaken in all this above explanation!
Now we can continue with Nest:
from the documentation we have this example:
Nest helps generate keys by providing chain namespaces that are already connected to Redis:
>> event = Nest.new("event") >> event[3][:attendees].sadd("Albert") >> event[3][:attendees].smembers => ["Albert"]
but here I am not sure that Nest will help us do the same thing as redis-namespace, or help us just create replaceable keys.
What is the difference between redis-namespace and Nest?