ruby - Setting array as hash's value in Redis -


i'm using redis ruby , i'd redis make hash in value array. however, array value key, value key (shortly - hash in hash).

arr = ["this", "is", "an", "array"] r = redis.new r.hset("super_key", "key", arr) 

which gives me error: err wrong number of arguments 'hset' command.

i'd expect hash this:

{ "super_key" => { "key" => ["this", "is", "an", "array"] } } 

so correct way of performing action?

not 100% sure what's making method angry, you're using in way doesn't allow. the redis gem documentation:

redis stores strings values. if want store object, can use serialization mechanism such json...

so try storing array.to_json, , use json.parse(obj) again.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -