Class: Kredis::Types::Proxying

Inherits:
Object
  • Object
show all
Defined in:
lib/kredis/types/proxying.rb

Direct Known Subclasses

Counter, Enum, Flag, Hash, List, OrderedSet, Scalar, Set, Slots

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(redis, key, **options) ⇒ Proxying

Returns a new instance of Proxying.



12
13
14
15
16
17
# File 'lib/kredis/types/proxying.rb', line 12

def initialize(redis, key, **options)
  @redis = redis
  @key = key
  @proxy = Kredis::Types::Proxy.new(redis, key)
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



6
7
8
# File 'lib/kredis/types/proxying.rb', line 6

def key
  @key
end

#proxyObject

Returns the value of attribute proxy.



6
7
8
# File 'lib/kredis/types/proxying.rb', line 6

def proxy
  @proxy
end

Class Method Details

.proxying(*commands) ⇒ Object



8
9
10
# File 'lib/kredis/types/proxying.rb', line 8

def self.proxying(*commands)
  delegate(*commands, to: :proxy)
end

Instance Method Details

#failsafe(returning: nil, &block) ⇒ Object



19
20
21
# File 'lib/kredis/types/proxying.rb', line 19

def failsafe(returning: nil, &block)
  proxy.suppress_failsafe_with(returning: returning, &block)
end

#unproxied_redisObject



23
24
25
26
27
# File 'lib/kredis/types/proxying.rb', line 23

def unproxied_redis
  # Generally, this should not be used. It's only here for the rare case where we need to
  # call Redis commands that don't reference a key and don't want to be pipelined.
  @redis
end