Class: Redis::ScriptManager::Configuration

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

Overview

Configuration interface for Redis::ScriptManager.

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



264
265
266
267
268
269
270
271
# File 'lib/redis/script_manager.rb', line 264

def initialize
  @do_preload         = nil
  @max_tiny_lua       = nil
  @preload_cache_size = nil
  @do_minify_lua      = nil
  @stats_prefix       = nil
  @statsd             = nil
end

Instance Method Details

#do_minify_luaObject

Defaults to false.

If true, all Lua is minified conservatively to save bandwidth before any other logic or evaluation.



308
309
310
# File 'lib/redis/script_manager.rb', line 308

def do_minify_lua
  @do_minify_lua || false
end

#do_minify_lua=(do_minify_lua) ⇒ Object



311
312
313
# File 'lib/redis/script_manager.rb', line 311

def do_minify_lua=(do_minify_lua)
  @do_minify_lua = [true,'true'].include?(do_minify_lua)
end

#do_preloadObject

Defaults to false.

If true, shas are preloaded for each Redis connection (which make safe to use EVALSHA even in pipelines).



334
335
336
# File 'lib/redis/script_manager.rb', line 334

def do_preload
  @do_preload || false
end

#do_preload=(do_preload) ⇒ Object



337
338
339
# File 'lib/redis/script_manager.rb', line 337

def do_preload=(do_preload)
  @do_preload = [true,'true'].include?(do_preload)
end

#max_tiny_luaObject

Scripts shorter than max_tiny_lua are always EVALed.

We skip all logic regarding EVALSHA, extra round-trips for SCRIPT LOAD, etc.

Defaults to 512. Integers and Strings which convert to Integers OK.



322
323
324
# File 'lib/redis/script_manager.rb', line 322

def max_tiny_lua
  @max_tiny_lua || 512
end

#max_tiny_lua=(max_tiny_lua) ⇒ Object



325
326
327
# File 'lib/redis/script_manager.rb', line 325

def max_tiny_lua=(max_tiny_lua)
  @max_tiny_lua = max_tiny_lua.to_i
end

#preload_cache_sizeObject

The cache of shas which have been preloaded is not allowed to grow larger than this value.

Defaults to 1000.



346
347
348
# File 'lib/redis/script_manager.rb', line 346

def preload_cache_size
  @preload_cache_size || 1000
end

#preload_cache_size=(preload_cache_size) ⇒ Object



349
350
351
# File 'lib/redis/script_manager.rb', line 349

def preload_cache_size=(preload_cache_size)
  @preload_cache_size = preload_cache_size.to_i
end

#stats_prefixObject

Defaults to ”.

Prefixed onto all metrics.



293
294
295
# File 'lib/redis/script_manager.rb', line 293

def stats_prefix
  @stats_prefix || ''
end

#stats_prefix=(stats_prefix) ⇒ Object



296
297
298
299
300
301
# File 'lib/redis/script_manager.rb', line 296

def stats_prefix=(stats_prefix)
  if stats_prefix && !stats_prefix.is_a?(String)
    raise ArgumentError, "bogus stats_prefix"
  end
  @stats_prefix = stats_prefix || ''
end

#statsdObject

Defaults to nil. If non-nil, lots of stats will be tracked via statsd.increment and statsd.timing.



276
277
278
# File 'lib/redis/script_manager.rb', line 276

def statsd
  @statsd || nil
end

#statsd=(statsd) ⇒ Object



279
280
281
282
283
284
285
286
287
# File 'lib/redis/script_manager.rb', line 279

def statsd=(statsd)
  if statsd && !statsd.respond_to?(:increment)
    raise ArgumentError, "bogus statsd A #{statsd}"
  end
  if statsd && !statsd.respond_to?(:timing)
    raise ArgumentError, "bogus statsd B #{statsd}"
  end
  @statsd = statsd
end