module Kredis::Types

Public Instance Methods

boolean(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 29
def boolean(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :boolean, default: default, expires_in: expires_in)
end
counter(key, expires_in: nil, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 42
def counter(key, expires_in: nil, config: :shared, after_change: nil)
  type_from(Counter, config, key, after_change: after_change, expires_in: expires_in)
end
cycle(key, values:, expires_in: nil, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 46
def cycle(key, values:, expires_in: nil, config: :shared, after_change: nil)
  type_from(Cycle, config, key, after_change: after_change, values: values, expires_in: expires_in)
end
datetime(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 33
def datetime(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :datetime, default: default, expires_in: expires_in)
end
decimal(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 21
def decimal(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :decimal, default: default, expires_in: expires_in)
end
enum(key, values:, default:, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 54
def enum(key, values:, default:, config: :shared, after_change: nil)
  type_from(Enum, config, key, after_change: after_change, values: values, default: default)
end
flag(key, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 50
def flag(key, config: :shared, after_change: nil)
  type_from(Flag, config, key, after_change: after_change)
end
float(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 25
def float(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :float, default: default, expires_in: expires_in)
end
hash(key, typed: :string, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 58
def hash(key, typed: :string, config: :shared, after_change: nil)
  type_from(Hash, config, key, after_change: after_change, typed: typed)
end
integer(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 17
def integer(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :integer, default: default, expires_in: expires_in)
end
json(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 37
def json(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :json, default: default, expires_in: expires_in)
end
list(key, typed: :string, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 62
def list(key, typed: :string, config: :shared, after_change: nil)
  type_from(List, config, key, after_change: after_change, typed: typed)
end
proxy(key, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 4
def proxy(key, config: :shared, after_change: nil)
  type_from(Proxy, config, key, after_change: after_change)
end
scalar(key, typed: :string, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 9
def scalar(key, typed: :string, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: typed, default: default, expires_in: expires_in)
end
set(key, typed: :string, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 70
def set(key, typed: :string, config: :shared, after_change: nil)
  type_from(Set, config, key, after_change: after_change, typed: typed)
end
slot(key, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 74
def slot(key, config: :shared, after_change: nil)
  type_from(Slots, config, key, after_change: after_change, available: 1)
end
slots(key, available:, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 78
def slots(key, available:, config: :shared, after_change: nil)
  type_from(Slots, config, key, after_change: after_change, available: available)
end
string(key, default: nil, config: :shared, after_change: nil, expires_in: nil) click to toggle source
# File lib/kredis/types.rb, line 13
def string(key, default: nil, config: :shared, after_change: nil, expires_in: nil)
  type_from(Scalar, config, key, after_change: after_change, typed: :string, default: default, expires_in: expires_in)
end
unique_list(key, typed: :string, limit: nil, config: :shared, after_change: nil) click to toggle source
# File lib/kredis/types.rb, line 66
def unique_list(key, typed: :string, limit: nil, config: :shared, after_change: nil)
  type_from(UniqueList, config, key, after_change: after_change, typed: typed, limit: limit)
end

Private Instance Methods

type_from(type_klass, config, key, after_change: nil, **options) click to toggle source
# File lib/kredis/types.rb, line 83
def type_from(type_klass, config, key, after_change: nil, **options)
  type_klass.new(configured_for(config), namespaced_key(key), **options).then do |type|
    after_change ? CallbacksProxy.new(type, after_change) : type
  end
end