Sha256: 828ae262056b5144a7b24ddb5939c55453ec58b4fa07c3e8276c1275eaa81bd1

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 Bytes

Contents

# frozen_string_literal: true

require 'redis'

module BellyWash
  module Driver
    class Redis
      attr_accessor :prefix

      def initialize(client = ::Redis.current, prefix: 'bw')
        @client = client
        @prefix = prefix
      end

      def inc(key:, **values)
        pkey = [@prefix, key].join('::')
        values.each do |k, c|
          @client.hincrby(pkey, k, c)
        end
      end

      def get(key:)
        pkey = [@prefix, key].join('::')
        @client.hgetall(pkey)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belly_wash-0.1.1 lib/belly_wash/driver/redis.rb