Sha256: 39de7ca8ecafd9d6fd44b36c466f8fd497502cd609a1cf440fabe33c5aebf676

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

module Tabs
  module Storage
    extend self

    def redis
      @redis ||= Config.redis
    end

    def exists(key)
      redis.get("tabs:#{key}")
    end

    def get(key)
      redis.get("tabs:#{key}")
    end

    def mget(*keys)
      prefixed_keys = keys.map { |k| "tabs:#{k}" }
      redis.mget(*prefixed_keys)
    end

    def set(key, value)
      redis.set("tabs:#{key}", value)
    end

    def del(*keys)
      prefixed_keys = keys.map { |k| "tabs:#{k}" }
      redis.del(*prefixed_keys)
    end

    def incr(key)
      redis.incr("tabs:#{key}")
    end

    def rpush(key, value)
      redis.rpush("tabs:#{key}", value)
    end

    def sadd(key, *values)
      redis.sadd("tabs:#{key}", *values)
    end

    def smembers(key)
      redis.smembers("tabs:#{key}")
    end

    def hget(key, field)
      redis.hget("tabs:#{key}", field)
    end

    def hset(key, field, value)
      redis.hset("tabs:#{key}", field, value)
    end

    def hdel(key, field)
      redis.hdel("tabs:#{key}", field)
    end

    def hkeys(key)
      redis.hkeys("tabs:#{key}")
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tabs-0.5.6 lib/tabs/storage.rb
tabs-0.5.5 lib/tabs/storage.rb
tabs-0.5.4 lib/tabs/storage.rb
tabs-0.5.3 lib/tabs/storage.rb
tabs-0.5.2 lib/tabs/storage.rb