Sha256: a4c95602058298f69a1df577203cf03e68cec32d4d30176d58f0e5759684d3fd
Contents?: true
Size: 812 Bytes
Versions: 3
Compression:
Stored size: 812 Bytes
Contents
require 'redis' module Lit extend self def redis return @redis if @redis @redis = Redis.connect(:thread_safe => true) @redis end class RedisStorage def initialize Lit.redis end def [](key) Lit.redis.get(_prefixed_key(key)) end def []=(k, v) Lit.redis.set(_prefixed_key(k).to_s, v.to_s) end def clear Lit.redis.del self.keys save end def keys Lit.redis.keys(_prefixed_key+"*") end def has_key?(key) Lit.redis.exists(_prefixed_key(key)) end private def _prefixed_key(key="") prefix = "lit:" if Lit.storage_options.is_a?(Hash) prefix += "#{Lit.storage_options[:prefix]}:" if Lit.storage_options.has_key?(:prefix) end prefix+key end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lit-0.0.4.2 | lib/lit/adapters/redis_storage.rb |
lit-0.0.4.1 | lib/lit/adapters/redis_storage.rb |
lit-0.0.4 | lib/lit/adapters/redis_storage.rb |