Class: Conflow::Redis::Script Private

Inherits:
Object
  • Object
show all
Defined in:
lib/conflow/redis/script.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Main class for scripts, handling logic of executing and caching scripts.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cache_scriptsObject

This options decides whether scripts used by the gem will be cached in Redis or not. See Redis EVAL and Redis EVALSHA.

Examples:

Disable caching scripts (set this in your initializer)

Conflow::Redis::Script.cache_scripts = false


10
11
12
# File 'lib/conflow/redis/script.rb', line 10

def cache_scripts
  @cache_scripts
end

.scriptString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns LUA script of this Conflow::Redis::Script.

Returns:

  • (String)

    LUA script of this Conflow::Redis::Script



12
13
14
# File 'lib/conflow/redis/script.rb', line 12

def script
  @script
end

Class Method Details

.call(keys, args = []) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes script in Redis with given arguments.

Parameters:

  • keys (Array<String>)

    Array of keys

  • args (Array<Object>) (defaults to: [])

    Array of arguments of the script



38
39
40
# File 'lib/conflow/redis/script.rb', line 38

def call(*args)
  Conflow.redis.with { |conn| send(command, conn, args) }
end

.inherited(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sets cache_scripts option on inherited scripts



15
16
17
18
19
# File 'lib/conflow/redis/script.rb', line 15

def inherited(base)
  scripts << base
  base.cache_scripts = cache_scripts
  super
end