async-redis 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +57 -0
- data/async-redis.gemspec +3 -2
- data/lib/async/redis.rb +2 -1
- data/lib/async/redis/client.rb +10 -0
- data/lib/async/redis/context/multi.rb +11 -11
- data/lib/async/redis/context/nested.rb +2 -2
- data/lib/async/redis/context/subscribe.rb +2 -2
- data/lib/async/redis/methods/keys.rb +140 -0
- data/lib/async/redis/methods/lists.rb +118 -0
- data/lib/async/redis/methods/server.rb +44 -0
- data/lib/async/redis/methods/strings.rb +132 -0
- data/lib/async/redis/protocol/resp.rb +2 -2
- data/lib/async/redis/version.rb +1 -1
- metadata +12 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8921f2c6c6856463367ae38fcfa5e82a80616e5eda3430cc6eb40255c47f3ae
|
4
|
+
data.tar.gz: 53c01952126f0403bb75d3b82e522048e9b74ceb841a8c15d54a7fec980149b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bc75e38ba9b902f7f0f89c9a55fc8338c618492c3d30495b76e4da2976ae3509678ef0a51151b6668f6409c46e61fb6cccfda458dd039b5a8ce27d3b979e81a
|
7
|
+
data.tar.gz: 849ac7c70c39a57e25def98669e2843639a818f980b081805966d39589b9708cd23b1db13e06261e1c055e9c2c58c9f7bf3fadbfc0ab7d74786268c13dd6ebdc
|
data/.travis.yml
CHANGED
@@ -10,11 +10,13 @@ matrix:
|
|
10
10
|
- rvm: 2.4
|
11
11
|
- rvm: 2.5
|
12
12
|
- rvm: 2.6
|
13
|
+
- rvm: truffleruby
|
13
14
|
- rvm: jruby-head
|
14
15
|
env: JRUBY_OPTS="--debug -X+O"
|
15
16
|
- rvm: ruby-head
|
16
17
|
- rvm: rbx-3
|
17
18
|
allow_failures:
|
19
|
+
- rvm: truffleruby
|
18
20
|
- rvm: ruby-head
|
19
21
|
- rvm: jruby-head
|
20
22
|
- rvm: rbx-3
|
data/README.md
CHANGED
@@ -27,6 +27,63 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
+
### Basic Local Connection
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'async/redis'
|
34
|
+
|
35
|
+
endpoint = Async::Redis.local_endpoint
|
36
|
+
client = Async::Redis::Client.new(endpoint)
|
37
|
+
|
38
|
+
Async.run do
|
39
|
+
pp client.info
|
40
|
+
ensure
|
41
|
+
client.close
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### Variables
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'async/redis'
|
49
|
+
|
50
|
+
endpoint = Async::Redis.local_endpoint
|
51
|
+
client = Async::Redis::Client.new(endpoint)
|
52
|
+
|
53
|
+
Async.run do
|
54
|
+
client.set('X', 10)
|
55
|
+
pp client.get('X')
|
56
|
+
ensure
|
57
|
+
client.close
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
### Subscriptions
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require 'async/redis'
|
65
|
+
require 'json'
|
66
|
+
|
67
|
+
endpoint = Async::Redis.local_endpoint
|
68
|
+
client = Async::Redis::Client.new(endpoint)
|
69
|
+
|
70
|
+
Async.run do |task|
|
71
|
+
subscriber = task.async do
|
72
|
+
client.subscribe 'status.frontend' do |context|
|
73
|
+
type, name, message = context.listen
|
74
|
+
|
75
|
+
pp type, name, message
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
publisher = task.async do
|
80
|
+
client.publish 'status.frontend', 'good'
|
81
|
+
end
|
82
|
+
ensure
|
83
|
+
client.close
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
30
87
|
## Contributing
|
31
88
|
|
32
89
|
1. Fork it
|
data/async-redis.gemspec
CHANGED
@@ -13,15 +13,16 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
14
|
f.match(%r{^(test|spec|features)/})
|
15
15
|
end
|
16
|
+
|
16
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
18
|
spec.require_paths = ["lib"]
|
18
19
|
|
19
20
|
spec.add_dependency("async", "~> 1.8")
|
20
|
-
spec.add_dependency("async-io", "~> 1.10
|
21
|
+
spec.add_dependency("async-io", "~> 1.10")
|
21
22
|
|
22
23
|
spec.add_development_dependency "async-rspec", "~> 1.1"
|
23
24
|
|
24
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
25
26
|
spec.add_development_dependency "rspec", "~> 3.6"
|
26
27
|
spec.add_development_dependency "rake"
|
27
28
|
end
|
data/lib/async/redis.rb
CHANGED
data/lib/async/redis/client.rb
CHANGED
@@ -23,6 +23,11 @@ require_relative 'pool'
|
|
23
23
|
require_relative 'context/multi'
|
24
24
|
require_relative 'context/subscribe'
|
25
25
|
|
26
|
+
require_relative 'methods/strings'
|
27
|
+
require_relative 'methods/keys'
|
28
|
+
require_relative 'methods/lists'
|
29
|
+
require_relative 'methods/server'
|
30
|
+
|
26
31
|
require 'async/io'
|
27
32
|
|
28
33
|
module Async
|
@@ -32,6 +37,11 @@ module Async
|
|
32
37
|
end
|
33
38
|
|
34
39
|
class Client
|
40
|
+
include Methods::Strings
|
41
|
+
include Methods::Keys
|
42
|
+
include Methods::Lists
|
43
|
+
include Methods::Server
|
44
|
+
|
35
45
|
def initialize(endpoint = Redis.local_endpoint, protocol = Protocol::RESP, **options)
|
36
46
|
@endpoint = endpoint
|
37
47
|
@protocol = protocol
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -21,10 +21,18 @@
|
|
21
21
|
|
22
22
|
require_relative 'nested'
|
23
23
|
|
24
|
+
require_relative '../methods/strings'
|
25
|
+
require_relative '../methods/keys'
|
26
|
+
require_relative '../methods/lists'
|
27
|
+
|
24
28
|
module Async
|
25
29
|
module Redis
|
26
30
|
module Context
|
27
31
|
class Multi < Nested
|
32
|
+
include Methods::Strings
|
33
|
+
include Methods::Keys
|
34
|
+
include Methods::Lists
|
35
|
+
|
28
36
|
def initialize(pool, *args)
|
29
37
|
super(pool)
|
30
38
|
|
@@ -32,20 +40,12 @@ module Async
|
|
32
40
|
@connection.read_response
|
33
41
|
end
|
34
42
|
|
35
|
-
def set(key, value)
|
36
|
-
return send_command('SET', key, value)
|
37
|
-
end
|
38
|
-
|
39
|
-
def get(key)
|
40
|
-
return send_command 'GET', key
|
41
|
-
end
|
42
|
-
|
43
43
|
def execute
|
44
|
-
return
|
44
|
+
return call 'EXEC'
|
45
45
|
end
|
46
46
|
|
47
47
|
def discard
|
48
|
-
return
|
48
|
+
return call 'DISCARD'
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -35,7 +35,7 @@ module Async
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def call(command, *args)
|
39
39
|
@connection.write_request([command, *args])
|
40
40
|
return @connection.read_response
|
41
41
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
-
#
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -66,7 +66,7 @@ module Async
|
|
66
66
|
return response
|
67
67
|
else
|
68
68
|
@channels.subtract(channels)
|
69
|
-
return
|
69
|
+
return call 'UNSUBSCRIBE', *channels
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'date'
|
23
|
+
|
24
|
+
module Async
|
25
|
+
module Redis
|
26
|
+
module Methods
|
27
|
+
module Keys
|
28
|
+
def del(key, *keys)
|
29
|
+
return call('DEL', key, *keys)
|
30
|
+
end
|
31
|
+
|
32
|
+
def dump(key)
|
33
|
+
return call('DUMP', key)
|
34
|
+
end
|
35
|
+
|
36
|
+
def exists(key, *keys)
|
37
|
+
return call('EXISTS', key, *keys)
|
38
|
+
end
|
39
|
+
|
40
|
+
def expire(key, seconds)
|
41
|
+
return call('EXPIRE', key, seconds)
|
42
|
+
end
|
43
|
+
|
44
|
+
def expireat(key, time)
|
45
|
+
case time
|
46
|
+
when DateTime, Time, Date
|
47
|
+
timestamp = time.strftime('%s').to_i
|
48
|
+
else
|
49
|
+
timestamp = time
|
50
|
+
end
|
51
|
+
|
52
|
+
return call('EXPIREAT', key, timestamp)
|
53
|
+
end
|
54
|
+
|
55
|
+
def keys(pattern)
|
56
|
+
return call('KEYS', pattern)
|
57
|
+
end
|
58
|
+
|
59
|
+
def migrate
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def move(key, db)
|
64
|
+
return call('MOVE', key, db)
|
65
|
+
end
|
66
|
+
|
67
|
+
def object
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
def persist(key)
|
72
|
+
return call('PERSIST', key)
|
73
|
+
end
|
74
|
+
|
75
|
+
def pexpire(key, milliseconds)
|
76
|
+
return call('PEXPIRE', milliseconds)
|
77
|
+
end
|
78
|
+
|
79
|
+
def pexpireat(key, time)
|
80
|
+
case time.class
|
81
|
+
when DateTime, Time, Date
|
82
|
+
timestamp = time.strftime('%Q').to_i
|
83
|
+
else
|
84
|
+
timestamp = time
|
85
|
+
end
|
86
|
+
|
87
|
+
return call('PEXPIREAT', key, timestamp)
|
88
|
+
end
|
89
|
+
|
90
|
+
def pttl(key)
|
91
|
+
return call('PTTL', key)
|
92
|
+
end
|
93
|
+
|
94
|
+
def randomkey
|
95
|
+
return call('RANDOMKEY')
|
96
|
+
end
|
97
|
+
|
98
|
+
def rename(key, new_key)
|
99
|
+
return call('RENAME', key, new_key)
|
100
|
+
end
|
101
|
+
|
102
|
+
def renamenx(key, new_key)
|
103
|
+
return call('RENAMENX', key, new_key)
|
104
|
+
end
|
105
|
+
|
106
|
+
def restore(key, serialized_value, ttl=0)
|
107
|
+
return call('RESTORE', key, ttl, serialized_value)
|
108
|
+
end
|
109
|
+
|
110
|
+
def sort
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
def touch(key, *keys)
|
115
|
+
return call('TOUCH', key, *keys)
|
116
|
+
end
|
117
|
+
|
118
|
+
def ttl(key)
|
119
|
+
return call('TTL', key)
|
120
|
+
end
|
121
|
+
|
122
|
+
def type(key)
|
123
|
+
return call('TYPE', key)
|
124
|
+
end
|
125
|
+
|
126
|
+
def unlink(key)
|
127
|
+
return call('UNLINK', key)
|
128
|
+
end
|
129
|
+
|
130
|
+
def wait(newreplicas, timeout)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
def scan
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Async
|
23
|
+
module Redis
|
24
|
+
module Methods
|
25
|
+
module Lists
|
26
|
+
def blpop(ttl=0, *keys)
|
27
|
+
return call('BLPOP', *keys, ttl)
|
28
|
+
end
|
29
|
+
|
30
|
+
def brpop(ttl=0, *keys)
|
31
|
+
return call('BRPOP', *keys, ttl)
|
32
|
+
end
|
33
|
+
|
34
|
+
def brpoplpush(sorce, destination, timeout)
|
35
|
+
return call('BRPOPLPUSH', source, destination, timeout)
|
36
|
+
end
|
37
|
+
|
38
|
+
def lindex(key, index)
|
39
|
+
return call('LINDEX', key, index)
|
40
|
+
end
|
41
|
+
|
42
|
+
def linsert(key, position=:before, index, value)
|
43
|
+
if position == :before
|
44
|
+
offset = 'BEFORE'
|
45
|
+
else
|
46
|
+
offset = 'AFTER'
|
47
|
+
end
|
48
|
+
|
49
|
+
return call('LINSERT', key, offset, index, value)
|
50
|
+
end
|
51
|
+
|
52
|
+
def llen(key)
|
53
|
+
return call('LLEN', key)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lpop(key)
|
57
|
+
return call('LPOP', key)
|
58
|
+
end
|
59
|
+
|
60
|
+
def lpush(key, value, *values)
|
61
|
+
case value
|
62
|
+
when Array
|
63
|
+
values = value
|
64
|
+
else
|
65
|
+
values = [value] + values
|
66
|
+
end
|
67
|
+
|
68
|
+
return call('LPUSH', key, *values)
|
69
|
+
end
|
70
|
+
|
71
|
+
def lpushx(key, value)
|
72
|
+
return call('LPUSHX', key, value)
|
73
|
+
end
|
74
|
+
|
75
|
+
def lrange(key, start, stop)
|
76
|
+
return call('LRANGE', key. start, stop)
|
77
|
+
end
|
78
|
+
|
79
|
+
def lrem(key, count, value)
|
80
|
+
return call('LREM', key, count)
|
81
|
+
end
|
82
|
+
|
83
|
+
def lset(key, index, values)
|
84
|
+
return call('LSET', key, index, values)
|
85
|
+
end
|
86
|
+
|
87
|
+
def ltrim(key, start, stop)
|
88
|
+
return call('LTRIM', key, start, stop)
|
89
|
+
end
|
90
|
+
|
91
|
+
def rpop(key)
|
92
|
+
return call('RPOP', key)
|
93
|
+
end
|
94
|
+
|
95
|
+
def rpoplpush(source, destination=nil)
|
96
|
+
destination = source if destination.nil?
|
97
|
+
|
98
|
+
return call('RPOPLPUSH', source, destination)
|
99
|
+
end
|
100
|
+
|
101
|
+
def rpush(key, value, *values)
|
102
|
+
case value
|
103
|
+
when Array
|
104
|
+
values = value
|
105
|
+
else
|
106
|
+
values = [value] + values
|
107
|
+
end
|
108
|
+
|
109
|
+
return call('RPUSH', key, *values)
|
110
|
+
end
|
111
|
+
|
112
|
+
def rpushx(key, value)
|
113
|
+
return call('RPUSHX', key, value)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Async
|
23
|
+
module Redis
|
24
|
+
module Methods
|
25
|
+
module Server
|
26
|
+
# Get info from server.
|
27
|
+
# @return [Hash] the server metadata.
|
28
|
+
def info
|
29
|
+
metadata = {}
|
30
|
+
|
31
|
+
call('INFO').each_line(Protocol::CRLF) do |line|
|
32
|
+
key, value = line.split(':')
|
33
|
+
|
34
|
+
if value
|
35
|
+
metadata[key.to_sym] = value.chomp!
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
return metadata
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
# Copyright, 2018, by Huba Nagy.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Async
|
23
|
+
module Redis
|
24
|
+
module Methods
|
25
|
+
module Strings
|
26
|
+
def append(key, value)
|
27
|
+
return call('APPEND', key, value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def bitcount(key, *range)
|
31
|
+
return call('BITCOUNT', key, *range)
|
32
|
+
end
|
33
|
+
|
34
|
+
def decr(key)
|
35
|
+
return call('DECR', key)
|
36
|
+
end
|
37
|
+
|
38
|
+
def decrby(key, decrement)
|
39
|
+
return call('DECRBY', key, decrement)
|
40
|
+
end
|
41
|
+
|
42
|
+
def get(key)
|
43
|
+
return call('GET', key)
|
44
|
+
end
|
45
|
+
|
46
|
+
def getbit(key, offset)
|
47
|
+
return call('GETBIT', key, offset)
|
48
|
+
end
|
49
|
+
|
50
|
+
def getrange(key, start_index, end_index)
|
51
|
+
return call('GETRANGE', key, start_index, end_index)
|
52
|
+
end
|
53
|
+
|
54
|
+
def getset(key, value)
|
55
|
+
return call('GETSET', key, value)
|
56
|
+
end
|
57
|
+
|
58
|
+
def incr(key)
|
59
|
+
return call('INCR', key)
|
60
|
+
end
|
61
|
+
|
62
|
+
def incrby(key, increment)
|
63
|
+
return call('INCRBY', key, increment)
|
64
|
+
end
|
65
|
+
|
66
|
+
def incrbyfloat(key, increment)
|
67
|
+
return call('INCRBYFLOAT', key, increment)
|
68
|
+
end
|
69
|
+
|
70
|
+
def mget(key, *keys)
|
71
|
+
return call('MGET', key, *keys)
|
72
|
+
end
|
73
|
+
|
74
|
+
def mset(pairs)
|
75
|
+
flattened_pairs = pairs.keys.zip(pairs.values).flatten
|
76
|
+
return call('MSET', *flattened_pairs)
|
77
|
+
end
|
78
|
+
|
79
|
+
def msetnx(pairs)
|
80
|
+
flattened_pairs = pairs.keys.zip(pairs.values).flatten
|
81
|
+
return call('MSETNX', *flattened_pairs)
|
82
|
+
end
|
83
|
+
|
84
|
+
def psetex(key, milliseconds, value)
|
85
|
+
return set key, value, milliseconds: milliseconds
|
86
|
+
end
|
87
|
+
|
88
|
+
def set(key, value, **options)
|
89
|
+
arguments = []
|
90
|
+
|
91
|
+
if options.has_key? :seconds
|
92
|
+
arguments << 'EX'
|
93
|
+
arguments << options[:seconds]
|
94
|
+
end
|
95
|
+
|
96
|
+
if options.has_key? :milliseconds
|
97
|
+
arguments << 'PX'
|
98
|
+
arguments << options[:milliseconds]
|
99
|
+
end
|
100
|
+
|
101
|
+
if options[:condition] == :nx
|
102
|
+
arguments << 'NX'
|
103
|
+
elsif options[:condition] == :xx
|
104
|
+
arguments << 'XX'
|
105
|
+
end
|
106
|
+
|
107
|
+
return call('SET', key, value, *arguments)
|
108
|
+
end
|
109
|
+
|
110
|
+
def setbit(key, offset, value)
|
111
|
+
return call('SETBIT', key, offset, value)
|
112
|
+
end
|
113
|
+
|
114
|
+
def setex(key, seconds, value)
|
115
|
+
return set key, value, seconds: seconds
|
116
|
+
end
|
117
|
+
|
118
|
+
def setnx(key, value)
|
119
|
+
return set key, value, condition: :nx
|
120
|
+
end
|
121
|
+
|
122
|
+
def setrange(key, offset, value)
|
123
|
+
return call('SETRANGE', key, offset, value)
|
124
|
+
end
|
125
|
+
|
126
|
+
def strlen(key)
|
127
|
+
return call('STRLEN', key)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
data/lib/async/redis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-12-
|
12
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: async
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.10
|
34
|
+
version: '1.10'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.10
|
41
|
+
version: '1.10'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: async-rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -57,16 +57,16 @@ dependencies:
|
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - "
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - "
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +116,10 @@ files:
|
|
116
116
|
- lib/async/redis/context/multi.rb
|
117
117
|
- lib/async/redis/context/nested.rb
|
118
118
|
- lib/async/redis/context/subscribe.rb
|
119
|
+
- lib/async/redis/methods/keys.rb
|
120
|
+
- lib/async/redis/methods/lists.rb
|
121
|
+
- lib/async/redis/methods/server.rb
|
122
|
+
- lib/async/redis/methods/strings.rb
|
119
123
|
- lib/async/redis/pool.rb
|
120
124
|
- lib/async/redis/protocol/resp.rb
|
121
125
|
- lib/async/redis/version.rb
|