Class: XRuntime::Script
- Inherits:
-
Object
- Object
- XRuntime::Script
- Defined in:
- lib/x_runtime/script.rb
Instance Attribute Summary collapse
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
- #content ⇒ Object
- #evalsha(keys, argv) ⇒ Object
-
#initialize(redis) ⇒ Script
constructor
A new instance of Script.
- #sha ⇒ Object
Constructor Details
#initialize(redis) ⇒ Script
Returns a new instance of Script.
5 6 7 |
# File 'lib/x_runtime/script.rb', line 5 def initialize(redis) @redis = redis end |
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
3 4 5 |
# File 'lib/x_runtime/script.rb', line 3 def redis @redis end |
Instance Method Details
#content ⇒ Object
9 10 11 |
# File 'lib/x_runtime/script.rb', line 9 def content @script ||= IO.read(::File.join(::File.dirname(__FILE__),'redis.lua')) end |
#evalsha(keys, argv) ⇒ Object
18 19 20 |
# File 'lib/x_runtime/script.rb', line 18 def evalsha(keys, argv) @redis.evalsha(sha, :keys => keys, :argv => argv) end |
#sha ⇒ Object
13 14 15 16 |
# File 'lib/x_runtime/script.rb', line 13 def sha # 加载脚本 redis-server会将该脚本缓存起来 @sha ||= @redis.script(:load, content) end |