module AsyncStorage

frizen_string_literal: true

Constants

VERSION

Public Instance Methods

[](klass, **options) click to toggle source
# File lib/async_storage.rb, line 16
def [](klass, **options)
  Repo.new(klass, **options)
end
config() click to toggle source
# File lib/async_storage.rb, line 20
def config
  @config ||= Config.new
end
configure(&block) click to toggle source
# File lib/async_storage.rb, line 24
def configure(&block)
  return unless block_given?

  config.instance_eval(&block)
  @redis_pool = nil
  config
end
flush_all() click to toggle source
# File lib/async_storage/bath_actions.rb, line 6
def flush_all
  keys.inject(0) do |total, (key, cli)|
    total + cli.del(key)
  end
end
keys() click to toggle source
# File lib/async_storage/bath_actions.rb, line 12
def keys
  Enumerator.new do |yielder|
    redis_pool.with do |cli|
      cli.keys("#{config.namespace}:*").each { |key| yielder.yield(key, cli) }
    end
  end
end
redis_pool() click to toggle source
# File lib/async_storage.rb, line 32
def redis_pool
  @redis_pool ||= RedisPool.new(config.redis)
end