Sha256: 4ecb79d0bf08a05268d9ace146337d00739b2f6ecbaa00fe2a8ed53b95c6c4f6

Contents?: true

Size: 557 Bytes

Versions: 2

Compression:

Stored size: 557 Bytes

Contents

module Qless
  class Lua
    LUA_SCRIPT_DIR = File.expand_path("../qless-core/", __FILE__)
    
    def initialize(name, redis)
      @sha   = nil
      @name  = name
      @redis = redis
      reload()
    end
    
    def reload()
      @sha = @redis.script(:load, File.read(File.join(LUA_SCRIPT_DIR, "#{@name}.lua")))
    end
    
    def call(keys, args)
      begin
        return @redis.evalsha(@sha, keys.length, *(keys + args))
      rescue
        reload
        return @redis.evalsha(@sha, keys.length, *(keys + args))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qless-0.9.2 lib/qless/lua.rb
qless-0.9.1 lib/qless/lua.rb