Sha256: 792fa1acf6d6fdd9125a3302422fb37cbd41367066dbc72330f42ffe701022bf
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
# frozen_string_literal: true require 'redis' require_relative '../mixins/packer' module Trifle module Stats module Driver class Redis include Mixins::Packer attr_accessor :prefix def initialize(client = ::Redis.current, prefix: 'trfl') @client = client @prefix = prefix end def inc(key:, **values) pkey = [@prefix, key].join('::') self.class.pack(hash: values).each do |k, c| @client.hincrby(pkey, k, c) end end def set(key:, **values) pkey = [@prefix, key].join('::') @client.hmset(pkey, *self.class.pack(hash: values)) end def get(key:) pkey = [@prefix, key].join('::') self.class.unpack( hash: @client.hgetall(pkey) ) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trifle-stats-0.2.1 | lib/trifle/stats/driver/redis.rb |
trifle-stats-0.2.0 | lib/trifle/stats/driver/redis.rb |