Sha256: ed31c0997a516978cb9b3d3b1c248995baf90d23754221bc574fff5454f9337e
Contents?: true
Size: 946 Bytes
Versions: 6
Compression:
Stored size: 946 Bytes
Contents
require 'forwardable' module GameMachine module DataStores class Redis extend Forwardable def connect @pool = RedisLib::JedisPool.new(RedisLib::JedisPoolConfig.new, "localhost"); end def delete(key) query(:del,key) end def get(key) query(:get,key) end def set(key,value) query(:set,key, value) end def query(command,key,value=nil) jedis = @pool.get_resource case command when :get jedis.get(key) when :set res = jedis.set(key,value) res == 'OK' ? true : false when :del res = jedis.del(key) res == 1 ? true : false end rescue RedisLib::JedisConnectionException => e @pool.return_broken_resource(jedis) ensure @pool.return_resource(jedis) end def shutdown @pool.destroy end end end end
Version data entries
6 entries across 6 versions & 1 rubygems