Class: RedisScript
- Inherits:
-
Object
- Object
- RedisScript
- Defined in:
- lib/rails_observatory/redis/time_series/insertion.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(lua_string) ⇒ RedisScript
constructor
A new instance of RedisScript.
- #load_script ⇒ Object
- #redis ⇒ Object
Constructor Details
#initialize(lua_string) ⇒ RedisScript
Returns a new instance of RedisScript.
16 17 18 |
# File 'lib/rails_observatory/redis/time_series/insertion.rb', line 16 def initialize(lua_string) @script = lua_string end |
Class Method Details
.redis ⇒ Object
8 9 10 |
# File 'lib/rails_observatory/redis/time_series/insertion.rb', line 8 def self.redis Rails.configuration.rails_observatory.redis end |
Instance Method Details
#call(*args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails_observatory/redis/time_series/insertion.rb', line 20 def call(*args) @sha1 ||= load_script redis.call("EVALSHA", @sha1, 0, *args) rescue => e if e. =~ /NOSCRIPT/ @sha1 = load_script retry else raise e end end |
#load_script ⇒ Object
32 33 34 |
# File 'lib/rails_observatory/redis/time_series/insertion.rb', line 32 def load_script redis.call('SCRIPT', 'LOAD', @script) end |
#redis ⇒ Object
12 13 14 |
# File 'lib/rails_observatory/redis/time_series/insertion.rb', line 12 def redis self.class.redis end |