Class: Translator::RedisStore

Inherits:
Object
  • Object
show all
Defined in:
app/backends/translator/redis_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(redis) ⇒ RedisStore

Returns a new instance of RedisStore.


3
4
5
# File 'app/backends/translator/redis_store.rb', line 3

def initialize(redis)
  @redis = redis
end

Instance Method Details

#[](key) ⇒ Object


16
17
18
# File 'app/backends/translator/redis_store.rb', line 16

def [](key)
  @redis[key]
end

#[]=(key, value) ⇒ Object


11
12
13
14
# File 'app/backends/translator/redis_store.rb', line 11

def []=(key, value)
  value = nil if value == '' || value.nil?
  @redis[key] = ActiveSupport::JSON.encode(value)
end

#clear_databaseObject


24
25
26
# File 'app/backends/translator/redis_store.rb', line 24

def clear_database
  @redis.keys.clone.each {|key| @redis.del key }
end

#destroy_entry(key) ⇒ Object


20
21
22
# File 'app/backends/translator/redis_store.rb', line 20

def destroy_entry(key)
  @redis.del key
end

#keysObject


7
8
9
# File 'app/backends/translator/redis_store.rb', line 7

def keys
  @redis.keys
end