Class: Keymap::ConnectionAdapters::RedisAdapter
Defined Under Namespace
Classes: RedisHash, RedisList
Instance Attribute Summary collapse
#in_use, #last_use, #logger, #pool
Instance Method Summary
collapse
#clear_cache!, #close, #expire, #lease, #raw_connection, #requires_reloading?, #verify!
#outside_transaction?, #transaction
Constructor Details
#initialize(connection, pool, config) ⇒ RedisAdapter
Returns a new instance of RedisAdapter.
20
21
22
23
24
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 20
def initialize(connection, pool, config)
super(nil)
@config = config
reconnect!
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18
19
20
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 18
def config
@config
end
|
Instance Method Details
#active? ⇒ Boolean
30
31
32
33
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 30
def active?
return false unless @connection
@connection.ping == "PONG"
end
|
#adapter_name ⇒ Object
26
27
28
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 26
def adapter_name
'redis'
end
|
#begin_db_transaction ⇒ Object
61
62
63
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 61
def begin_db_transaction
raw_connection.multi
end
|
#commit_db_transaction ⇒ Object
65
66
67
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 65
def commit_db_transaction
raw_connection.exec
end
|
#delete(id) ⇒ Object
73
74
75
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 73
def delete(id)
raw_connection.del(id) != 0
end
|
#disconnect! ⇒ Object
Disconnects from the database if already connected. Otherwise, this method does nothing.
45
46
47
48
49
50
51
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 45
def disconnect!
super
unless @connection.nil?
@connection.quit
@connection = nil
end
end
|
#hash(id) ⇒ Object
77
78
79
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 77
def hash (id)
RedisHash.new(raw_connection, id)
end
|
#list(id) ⇒ Object
81
82
83
84
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 81
def list (id)
RedisList.new(raw_connection, id)
end
|
#reconnect! ⇒ Object
Also known as:
reset!
35
36
37
38
39
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 35
def reconnect!
disconnect!
connect
super
end
|
#rollback_db_transaction ⇒ Object
69
70
71
|
# File 'lib/keymap/connection_adapters/redis_adapter.rb', line 69
def rollback_db_transaction
raw_connection.discard
end
|