Class: Redi
- Inherits:
-
Object
- Object
- Redi
- Defined in:
- lib/redi/mock.rb,
lib/redi.rb,
lib/redi/pool.rb,
lib/redi/version.rb
Overview
provide a key to name to host:port mapping
should have a larger keyspace than servers, this allows scaling up the servers without changing the keyspace mapping
sample configuration:
-
:host: :port: :db: :buckets: 0 - 64
-
:host: :port: :db: :buckets: 65 - 127
Defined Under Namespace
Constant Summary collapse
- UNIMPLEMENTED_COMMANDS =
these commands are complicated to distribute across a pool and so for now are unimplemented. Translation: we are lazy.
%w[ keys move object randomkey rename renamenx eval mget mset msetnx brpoplpush rpoplpush sdiff sdiffstore sinter sinterstore smove sunion sunionstore zinterstore zunionstore psubscribe publish punsubscribe subscribe unsubscribe discard exec multi unwatch watch auth echo ping quit select bgrewriteaof bgsave config dbsize debug info lastsave monitor save shutdown slaveof slowlog sync ]
- VERSION =
"0.0.8"
Class Method Summary collapse
- .config ⇒ Object
- .config=(config) ⇒ Object
- .flushall ⇒ Object
- .flushdb ⇒ Object
-
.method_missing(cmd, *args) ⇒ Object
raise exceptions on unimplemented/unknown commands, delegate everything else down to the actual Redis connections.
- .mock! ⇒ Object
- .pool(mock = false) ⇒ Object
Class Method Details
.config ⇒ Object
46 47 48 |
# File 'lib/redi.rb', line 46 def self.config @config end |
.config=(config) ⇒ Object
42 43 44 |
# File 'lib/redi.rb', line 42 def self.config=(config) @config = config end |
.flushall ⇒ Object
33 34 35 |
# File 'lib/redi.rb', line 33 def self.flushall pool.flushall end |
.flushdb ⇒ Object
29 30 31 |
# File 'lib/redi.rb', line 29 def self.flushdb pool.flushdb end |
.method_missing(cmd, *args) ⇒ Object
raise exceptions on unimplemented/unknown commands, delegate everything else down to the actual Redis connections
21 22 23 24 25 26 27 |
# File 'lib/redi.rb', line 21 def self.method_missing( cmd, *args ) if UNIMPLEMENTED_COMMANDS.include?( cmd.to_s ) raise NotImplementedError, "#{cmd} has not yet been implemented. Patches welcome!" end pool.redis_by_key( args.first ).send( cmd, *args ) end |
.mock! ⇒ Object
7 8 9 |
# File 'lib/redi/mock.rb', line 7 def self.mock! pool(true).mock! end |