Class: Riddick::Backends::Redis

Inherits:
KeyValue
  • Object
show all
Defined in:
lib/riddick/backends/redis.rb,
lib/riddick/backends/redis/value.rb

Overview

Redis based key-value backend.

Defined Under Namespace

Classes: Value

Instance Attribute Summary

Attributes inherited from KeyValue

#i18n_backend

Instance Method Summary collapse

Methods inherited from KeyValue

#initialize

Constructor Details

This class inherits a constructor from Riddick::Backends::KeyValue

Instance Method Details

#delete_translation(k) ⇒ Object

Delete a translation from the store.



6
7
8
# File 'lib/riddick/backends/redis.rb', line 6

def delete_translation(k)
  store.del k
end

#translationsObject

Fetch and return custom translation as a hash of type: => ‘baz’. Values of the hash are of kind Riddick::Backends::Redis::Value, so it’s easy to determine whether they are custom translation or the predefined.



13
14
15
16
17
18
19
20
# File 'lib/riddick/backends/redis.rb', line 13

def translations
  keys = store.keys
  if keys.any?
    Hash[keys.zip store.mget(keys).map { |v| Riddick::Backends::Redis::Value.new v }]
  else
    {}
  end
end