Module: MeRedis::ZipToHash::PrependMethods

Defined in:
lib/me_redis/zip_to_hash.rb

Instance Method Summary collapse

Instance Method Details

#config(action, *args) ⇒ Object



25
26
27
28
# File 'lib/me_redis/zip_to_hash.rb', line 25

def config(action, *args)
  @hash_max_ziplist_entries = args[1].to_i if action.to_s == 'set' && args[0] == 'hash-max-ziplist-entries'
  super( action, *args )
end

#initialize(*args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/me_redis/zip_to_hash.rb', line 6

def initialize(*args, &block)
  super(*args, &block)

  # hash-max-ziplist-entries must be cashed, we can't ask Redis every time we need to zip keys,
  # cause it's less performant and impossible during pipelining.
  _config = config(:get, 'hash-max-ziplist-*' )
  @hash_max_ziplist_entries = _config['hash-max-ziplist-entries'].to_i
  if self.class.me_config.hash_max_ziplist_entries && @hash_max_ziplist_entries != self.class.me_config.hash_max_ziplist_entries
    #if me_config configures hash-max-ziplist-entries than we assume it global
    config(:set, 'hash-max-ziplist-entries', self.class.me_config.hash_max_ziplist_entries )
  end

  if self.class.me_config.hash_max_ziplist_value &&
      self.class.me_config.hash_max_ziplist_value != _config['hash-max-ziplist-value'].to_i

    config(:set, 'hash-max-ziplist-value', self.class.me_config.hash_max_ziplist_value)
  end
end