Class: Redic
- Inherits:
-
Object
show all
- Defined in:
- lib/redic.rb,
lib/redic/client.rb,
lib/redic/connection.rb
Defined Under Namespace
Modules: Connection
Classes: Client
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000) ⇒ Redic
Returns a new instance of Redic.
7
8
9
10
11
|
# File 'lib/redic.rb', line 7
def initialize(url = "redis://127.0.0.1:6379", timeout = 10_000_000)
@url = url
@client = Redic::Client.new(url, timeout)
@queue = []
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/redic.rb', line 5
def client
@client
end
|
#url ⇒ Object
Returns the value of attribute url.
4
5
6
|
# File 'lib/redic.rb', line 4
def url
@url
end
|
Instance Method Details
#call(*args) ⇒ Object
18
19
20
21
22
23
|
# File 'lib/redic.rb', line 18
def call(*args)
@client.connect do
@client.write(args)
@client.read
end
end
|
#commit ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/redic.rb', line 29
def commit
@client.connect do
@queue.each do |args|
@client.write(args)
end
@queue.map do
@client.read
end
end
ensure
@queue.clear
end
|
13
14
15
16
|
# File 'lib/redic.rb', line 13
def configure(url, timeout = 10_000_000)
@url = url
@client.configure(url, timeout)
end
|
#queue(*args) ⇒ Object
25
26
27
|
# File 'lib/redic.rb', line 25
def queue(*args)
@queue << args
end
|
#timeout ⇒ Object
43
44
45
|
# File 'lib/redic.rb', line 43
def timeout
@client.timeout
end
|