Sha256: 0e8772c030343ba3aaf8a8c3aeaa4ca54ba1836b3eeda24bd4343ec5e0cd7f41

Contents?: true

Size: 814 Bytes

Versions: 25

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

require 'redis'

module LinkedRails
  class Storage
    REDIS_DB = {
      cache: LinkedRails.cache_redis_database,
      persistent: LinkedRails.persistent_redis_database,
      stream: LinkedRails.stream_redis_database
    }.freeze
    KEYS = {
      manifest: 'cache:Manifest',
      redirect_exact: 'cache:Redirect:Exact',
      redirect_prefix: 'cache:Redirect:Prefix'
    }.freeze

    class << self
      %i[xadd].each do |method|
        define_method(method) do |db, *args|
          Redis.new(db: REDIS_DB.fetch(db)).send(method, *args)
        end
      end

      %i[hset hdel hget].each do |method|
        define_method(method) do |db, key, *args|
          Redis.new(db: REDIS_DB.fetch(db)).send(method, KEYS.fetch(key), *args)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
linked_rails-0.0.4.pre.g3aeec2263 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gacd5f04d4 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gb0b6aea40 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g792a1b887 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g58af47992 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g0ec6e30ca lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g9e3bcac55 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g222bfeeca lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gb254a2893 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g2c6c26e86 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.ge881247c3 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gfabf7e9f5 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g8c045be3a lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g8d7195543 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gfe77aae19 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.gc866c1806 lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g3e8f5731a lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g58e27be7f lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g96885856b lib/linked_rails/storage.rb
linked_rails-0.0.4.pre.g1faca9643 lib/linked_rails/storage.rb