Class: Redis::Asm
- Inherits:
-
Object
- Object
- Redis::Asm
- Defined in:
- lib/redis/asm.rb,
lib/redis/asm/version.rb
Constant Summary collapse
- SCRIPT_DIR =
File.('../../', __FILE__)
- SCRIPT =
File.read File.join(SCRIPT_DIR, "redis_asm.lua")
- SHA1 =
Digest::SHA1.hexdigest SCRIPT
- VERSION =
"0.1.2"
Instance Method Summary collapse
-
#initialize(redis) ⇒ Asm
constructor
A new instance of Asm.
- #search(key, needle, max_results = 10) ⇒ Object
Constructor Details
#initialize(redis) ⇒ Asm
Returns a new instance of Asm.
12 13 14 |
# File 'lib/redis/asm.rb', line 12 def initialize(redis) @redis = redis end |
Instance Method Details
#search(key, needle, max_results = 10) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/redis/asm.rb', line 16 def search(key, needle, max_results=10) begin @redis.evalsha(SHA1, :keys => [key], :argv => [needle, max_results]) rescue Exception => e if e. =~ /NOSCRIPT/ @redis.script(:load, SCRIPT) retry else raise e end end end |