humante / redis-browser

Web-based Redis browser that can work as standalone app or mounted Rails engine
MIT License
603 stars 67 forks source link

Redis::Store #18

Closed kikorb closed 9 years ago

kikorb commented 9 years ago

Hi, this morning I made a clone of the repository to modify to my needs.

I am using Redis::Store rather than Redis, because I am using Rails and I don't mind the extra set of features that the gem provides.

The fork is here in case you consider interesting the idea: https://github.com/kikorb/redis-browser BR, kikorb

teamon commented 9 years ago

If I understand correctly, you just "replaced" redis gem with redis-store gem, that under the hood uses the exact same redis gem anyway.

At the same time it seems like you have removed quite a lot of functionality from the browser itself.

So... what's the point in all that?

kikorb commented 9 years ago

No the idea is that when using Redis::Store you loose compatibility with Redis, so using the gem as is all the content is not decode properly and you don't see the values properly.

I am not saying this is an improvement I am saying this gives compatibility for people that uses Redis::Store in the application to see the values they are caching.

I added a new commit cleaning the views and adding a delete button in the "show" view. I am not suggesting that you merge this, this is something that is useful for me. But give a try to Redis::Store and you see that the compatilbility could be better. It might be neat if you add a configuration to decide on the client to use.

teamon commented 9 years ago

@kikorb Could you show me an example of such incompatibility?

kikorb commented 9 years ago

simple_object = OpenStruct.new({a: 1})
 => #<OpenStruct a=1> 
rs = Redis::Store.new db:0
 => #<Redis client v3.2.1 for redis://127.0.0.1:6379/0> 
rs.set :simple_object, simple_object
 => "OK" 
rs.get :simple_object
 => #<OpenStruct a=1> 
r = Redis.new db: 0
 => #<Redis client v3.2.1 for redis://127.0.0.1:6379/0> 
r.get :simple_object
 => "\u0004\bU:\u000FOpenStruct{\u0006:\u0006ai\u0006" 
r.type :simple_object
"string" 

Pretty much any object that is not a simple type or an structure of simple types.

kikorb commented 9 years ago

And you can get the picture of the result page when you have complex objects stored

kikorb commented 9 years ago

Redis::Store under the hood uses Redis, yes, but unless you want to redo all the things that happens before the under the hood part, you are left with no choice but to use Redis::Store again for reading.

kikorb commented 9 years ago

Again it was a suggestion, a lot of people uses redis store and it could beneficial for them. I love the gem you created and I am using it :)

teamon commented 9 years ago

Actually all redis-store does here is to marshal the data back and forth. While it might be convenient I really believe this is a bad practice and the raw: true options should be used wherever possible.

If anything, this could be implemented as a setting option to use redis-store marshaling if needed, but I'm going to keep the core functionality for proper redis data structure usage.