Class: Bridge::DB
- Inherits:
-
Redis
- Object
- Redis
- Bridge::DB
- Defined in:
- lib/bridge/db.rb
Instance Method Summary collapse
-
#namespace(ns) ⇒ Object
retrieves all values in a given namespace e.g.
- #open_tables ⇒ Object
Instance Method Details
#namespace(ns) ⇒ Object
retrieves all values in a given namespace e.g. server:name, server:port and server:location all belong in the server namespace
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bridge/db.rb', line 8 def namespace ns ns_keys = keys("#{ns.to_s}:*") ns_keys = ns_keys.inject({}) { |h,k| h.update(k => type(k)) } pipelined do ns_keys.each do |key,type| case type when 'hash' hgetall(key) else get(key) end end end end |
#open_tables ⇒ Object
23 24 25 |
# File 'lib/bridge/db.rb', line 23 def open_tables lrange('opentables',0,llen('opentables')).map(&:to_i) end |