lite-redis 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.fasterer.yml +19 -0
- data/.gitignore +11 -0
- data/.rspec +4 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +135 -0
- data/LICENSE.txt +21 -0
- data/README.md +108 -0
- data/Rakefile +8 -0
- data/_config.yml +1 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docs/CONNECTION.md +14 -0
- data/docs/GEO.md +14 -0
- data/docs/HASH.md +14 -0
- data/docs/HYPER_LOG_LOG.md +14 -0
- data/docs/KEY.md +14 -0
- data/docs/LIST.md +14 -0
- data/docs/PUB_SUB.md +31 -0
- data/docs/SCRIPT.md +14 -0
- data/docs/SET.md +14 -0
- data/docs/SORTED_SET.md +14 -0
- data/docs/STRING.md +14 -0
- data/docs/TRANSACTION.md +14 -0
- data/lib/generators/lite/redis/install_generator.rb +17 -0
- data/lib/generators/lite/redis/templates/install.rb +5 -0
- data/lib/lite/redis/base.rb +12 -0
- data/lib/lite/redis/configuration.rb +29 -0
- data/lib/lite/redis/connection.rb +12 -0
- data/lib/lite/redis/geo.rb +12 -0
- data/lib/lite/redis/hash.rb +12 -0
- data/lib/lite/redis/helpers/base_helper.rb +39 -0
- data/lib/lite/redis/helpers/connection_helper.rb +105 -0
- data/lib/lite/redis/helpers/geo_helper.rb +33 -0
- data/lib/lite/redis/helpers/hash_helper.rb +69 -0
- data/lib/lite/redis/helpers/hyper_log_log_helper.rb +21 -0
- data/lib/lite/redis/helpers/key_helper.rb +95 -0
- data/lib/lite/redis/helpers/list_helper.rb +133 -0
- data/lib/lite/redis/helpers/pub_sub_helper.rb +45 -0
- data/lib/lite/redis/helpers/script_helper.rb +21 -0
- data/lib/lite/redis/helpers/set_helper.rb +69 -0
- data/lib/lite/redis/helpers/sorted_set_helper.rb +136 -0
- data/lib/lite/redis/helpers/string_helper.rb +98 -0
- data/lib/lite/redis/helpers/transaction_helper.rb +29 -0
- data/lib/lite/redis/hyper_log_log.rb +12 -0
- data/lib/lite/redis/key.rb +12 -0
- data/lib/lite/redis/list.rb +12 -0
- data/lib/lite/redis/pub_sub.rb +12 -0
- data/lib/lite/redis/railtie.rb +16 -0
- data/lib/lite/redis/script.rb +12 -0
- data/lib/lite/redis/set.rb +12 -0
- data/lib/lite/redis/sorted_set.rb +12 -0
- data/lib/lite/redis/string.rb +12 -0
- data/lib/lite/redis/transaction.rb +12 -0
- data/lib/lite/redis/version.rb +9 -0
- data/lib/lite/redis.rb +16 -0
- data/lib/tasks/redis.rake +31 -0
- data/lite-redis.gemspec +53 -0
- metadata +272 -0
data/docs/STRING.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# String
|
2
|
+
|
3
|
+
#### Usage
|
4
|
+
|
5
|
+
Please read the corresponding [helper](https://github.com/drexed/lite-redis/blob/master/lib/lite/redis/helpers/string_helper.rb) file to see all available methods.
|
6
|
+
|
7
|
+
Please read the corresponding [spec](https://github.com/drexed/lite-redis/blob/master/spec/lite/redis/string_spec.rb) file to see more example usages.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
string = Lite::Redis::String.new
|
11
|
+
string.create(:example1, '123') #=> 'OK'
|
12
|
+
|
13
|
+
Lite::Redis::String.find(:example1) #=> '123'
|
14
|
+
```
|
data/docs/TRANSACTION.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Transaction
|
2
|
+
|
3
|
+
#### Usage
|
4
|
+
|
5
|
+
Please read the corresponding [helper](https://github.com/drexed/lite-redis/blob/master/lib/lite/redis/helpers/transaction_helper.rb) file to see all available methods.
|
6
|
+
|
7
|
+
Please read the corresponding [spec](https://github.com/drexed/lite-redis/blob/master/spec/lite/redis/transaction_spec.rb) file to see more example usages.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
transaction = Lite::Redis::Transaction.new
|
11
|
+
transaction.multi { |m| m.set('foo', 's1') } #=> 'OK'
|
12
|
+
|
13
|
+
Lite::Redis::Transaction.discard #=> 'OK'
|
14
|
+
```
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
|
5
|
+
module Lite
|
6
|
+
module Redis
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
8
|
+
|
9
|
+
source_root File.expand_path('../templates', __FILE__)
|
10
|
+
|
11
|
+
def copy_initializer_file
|
12
|
+
copy_file('install.rb', 'config/initializers/lite-redis.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
|
6
|
+
class Configuration
|
7
|
+
|
8
|
+
attr_accessor :client
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@client = ::Redis.new
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configuration
|
17
|
+
@configuration ||= Configuration.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configuration=(config)
|
21
|
+
@configuration = config
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.configure
|
25
|
+
yield(configuration)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module BaseHelper
|
6
|
+
|
7
|
+
def initialize(redis = nil)
|
8
|
+
@client = redis
|
9
|
+
end
|
10
|
+
|
11
|
+
def client(redis = nil)
|
12
|
+
@client ||= redis ||= Lite::Redis.configuration.client
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def append?(order)
|
18
|
+
order.to_s == 'append'
|
19
|
+
end
|
20
|
+
|
21
|
+
def milliseconds?(format)
|
22
|
+
format.to_s == 'milliseconds'
|
23
|
+
end
|
24
|
+
|
25
|
+
def prepend?(order)
|
26
|
+
order.to_s == 'prepend'
|
27
|
+
end
|
28
|
+
|
29
|
+
def seconds?(format)
|
30
|
+
format.to_s == 'seconds'
|
31
|
+
end
|
32
|
+
|
33
|
+
def stringify_keys(*keys)
|
34
|
+
keys.map { |key, _| key.to_s }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module ConnectionHelper
|
6
|
+
|
7
|
+
def authenticate(password)
|
8
|
+
client.auth(password)
|
9
|
+
end
|
10
|
+
|
11
|
+
def connected?
|
12
|
+
client.connected?
|
13
|
+
end
|
14
|
+
|
15
|
+
def database(index)
|
16
|
+
client.select(index)
|
17
|
+
end
|
18
|
+
|
19
|
+
def database_id
|
20
|
+
client.database_id
|
21
|
+
end
|
22
|
+
|
23
|
+
def database_size
|
24
|
+
client.dbsize
|
25
|
+
end
|
26
|
+
|
27
|
+
def debug(*args)
|
28
|
+
client.debug(*args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def disconnect
|
32
|
+
client.disconnect
|
33
|
+
end
|
34
|
+
|
35
|
+
def echo(message)
|
36
|
+
client.echo(message)
|
37
|
+
end
|
38
|
+
|
39
|
+
def flush
|
40
|
+
client.flushdb
|
41
|
+
end
|
42
|
+
|
43
|
+
def flush_all
|
44
|
+
client.flushall
|
45
|
+
end
|
46
|
+
|
47
|
+
def info
|
48
|
+
client.info
|
49
|
+
end
|
50
|
+
|
51
|
+
def ping
|
52
|
+
client.ping
|
53
|
+
end
|
54
|
+
|
55
|
+
def quit
|
56
|
+
client.quit
|
57
|
+
end
|
58
|
+
|
59
|
+
def reconnect
|
60
|
+
client.reconnect
|
61
|
+
end
|
62
|
+
|
63
|
+
def rewrite_aof
|
64
|
+
client.bgrewriteaof
|
65
|
+
end
|
66
|
+
|
67
|
+
def save
|
68
|
+
client.bgsave
|
69
|
+
end
|
70
|
+
|
71
|
+
def saved_at
|
72
|
+
client.lastsave
|
73
|
+
end
|
74
|
+
|
75
|
+
def shutdown
|
76
|
+
client.shutdown
|
77
|
+
end
|
78
|
+
|
79
|
+
def slave_of(host, port)
|
80
|
+
client.slaveof(host, port)
|
81
|
+
end
|
82
|
+
|
83
|
+
def slowlog(command, length = nil)
|
84
|
+
client.slowlog(command, length)
|
85
|
+
end
|
86
|
+
|
87
|
+
def synchronize
|
88
|
+
client.synchronize
|
89
|
+
end
|
90
|
+
|
91
|
+
def time
|
92
|
+
client.time
|
93
|
+
end
|
94
|
+
|
95
|
+
def with_reconnect(&block)
|
96
|
+
client.with_reconnect(true, &block)
|
97
|
+
end
|
98
|
+
|
99
|
+
def without_reconnect(&block)
|
100
|
+
client.with_reconnect(false, &block)
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module GeoHelper
|
6
|
+
|
7
|
+
def create(key, *member)
|
8
|
+
client.geoadd(key.to_s, *member)
|
9
|
+
end
|
10
|
+
|
11
|
+
def hash(key, member)
|
12
|
+
client.geohash(key.to_s, member)
|
13
|
+
end
|
14
|
+
|
15
|
+
def position(key, member)
|
16
|
+
client.geopos(key.to_s, member)
|
17
|
+
end
|
18
|
+
|
19
|
+
def distance(key, member1, member2, unit = 'm')
|
20
|
+
client.geodist(key.to_s, member1, member2, unit.to_s)
|
21
|
+
end
|
22
|
+
|
23
|
+
def radius(*args, **geoptions)
|
24
|
+
client.georadius(*args, **geoptions)
|
25
|
+
end
|
26
|
+
|
27
|
+
def radius_member(*args, **geoptions)
|
28
|
+
client.georadiusbymember(*args, **geoptions)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module HashHelper
|
6
|
+
|
7
|
+
def find(key, field)
|
8
|
+
client.hget(key.to_s, field)
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_each(key, *args)
|
12
|
+
client.hmget(key.to_s, *args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all(key)
|
16
|
+
client.hgetall(key.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
def keys(key)
|
20
|
+
client.hkeys(key.to_s)
|
21
|
+
end
|
22
|
+
|
23
|
+
def values(key)
|
24
|
+
client.hvals(key.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
def value_length(key, field)
|
28
|
+
client.hstrlen(key.to_s, field)
|
29
|
+
end
|
30
|
+
|
31
|
+
def count(key)
|
32
|
+
client.hlen(key.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def exists?(key, field)
|
36
|
+
client.hexists(key.to_s, field)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create(key, field, value)
|
40
|
+
client.hset(key.to_s, field, value)
|
41
|
+
end
|
42
|
+
|
43
|
+
def create!(key, field, value)
|
44
|
+
client.hsetnx(key.to_s, field, value)
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_each(key, *args)
|
48
|
+
client.hmset(key.to_s, *args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def increment(key, field, value)
|
52
|
+
if value.is_a?(Float)
|
53
|
+
client.hincrbyfloat(key.to_s, field, value)
|
54
|
+
else
|
55
|
+
client.hincrby(key.to_s, field, value)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def destroy(key, *args)
|
60
|
+
client.hdel(key.to_s, *args)
|
61
|
+
end
|
62
|
+
|
63
|
+
def scan(key, cursor, opts = {})
|
64
|
+
client.hdel(key.to_s, cursor, opts)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module HyperLogLogHelper
|
6
|
+
|
7
|
+
def create(key, member)
|
8
|
+
client.pfadd(key.to_s, member)
|
9
|
+
end
|
10
|
+
|
11
|
+
def count(*args)
|
12
|
+
client.pfcount(*args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def merge(key, *keys)
|
16
|
+
client.pfmerge(key.to_s, *keys)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module KeyHelper
|
6
|
+
|
7
|
+
def exists?(key)
|
8
|
+
client.exists(key.to_s)
|
9
|
+
end
|
10
|
+
|
11
|
+
def type?(key)
|
12
|
+
client.type(key.to_s)
|
13
|
+
end
|
14
|
+
|
15
|
+
def ttl?(key, format = :seconds)
|
16
|
+
if seconds?(format)
|
17
|
+
client.ttl(key.to_s)
|
18
|
+
else
|
19
|
+
client.pttl(key.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def sort(key, opts = {})
|
24
|
+
client.sort(key.to_s, opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
def sample
|
28
|
+
client.randomkey
|
29
|
+
end
|
30
|
+
|
31
|
+
def rename(key, value)
|
32
|
+
client.rename(key.to_s, value.to_s)
|
33
|
+
end
|
34
|
+
|
35
|
+
def rename!(key, value)
|
36
|
+
client.renamenx(key.to_s, value.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy(key)
|
40
|
+
client.del(key.to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
def persist(key)
|
44
|
+
client.persist(key.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
def expire(key, seconds, format = :seconds)
|
48
|
+
if seconds?(format)
|
49
|
+
client.expire(key.to_s, seconds)
|
50
|
+
else
|
51
|
+
client.pexpire(key.to_s, seconds)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
alias expire_in expire
|
56
|
+
|
57
|
+
def expire_at(key, seconds, format = :seconds)
|
58
|
+
if seconds?(format)
|
59
|
+
client.expireat(key.to_s, seconds)
|
60
|
+
else
|
61
|
+
client.pexpireat(key.to_s, seconds)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def dump(key)
|
66
|
+
client.dump(key.to_s)
|
67
|
+
end
|
68
|
+
|
69
|
+
def match(pattern = '*')
|
70
|
+
client.keys(pattern.to_s)
|
71
|
+
end
|
72
|
+
|
73
|
+
def migrate(key, options)
|
74
|
+
client.migrate(key.to_s, options)
|
75
|
+
end
|
76
|
+
|
77
|
+
def move(key, destination)
|
78
|
+
client.move(key.to_s, destination)
|
79
|
+
end
|
80
|
+
|
81
|
+
def object(*args)
|
82
|
+
client.object(*args)
|
83
|
+
end
|
84
|
+
|
85
|
+
def restore(key, milliseconds, value)
|
86
|
+
client.restore(key.to_s, milliseconds, value)
|
87
|
+
end
|
88
|
+
|
89
|
+
def scan(cursor, opts = {})
|
90
|
+
client.scan(cursor, opts)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module ListHelper
|
6
|
+
|
7
|
+
def find(key, position = 1)
|
8
|
+
client.lindex(key.to_s, position - 1)
|
9
|
+
end
|
10
|
+
|
11
|
+
def first(key, limit = 1)
|
12
|
+
value = client.lrange(key.to_s, 0, -1)
|
13
|
+
return value.first if limit == 1
|
14
|
+
|
15
|
+
value.first(limit)
|
16
|
+
end
|
17
|
+
|
18
|
+
def last(key, limit = 1)
|
19
|
+
value = client.lrange(key.to_s, 0, -1)
|
20
|
+
return value.last if limit == 1
|
21
|
+
|
22
|
+
value.last(limit)
|
23
|
+
end
|
24
|
+
|
25
|
+
def between(key, start = 1, finish = 0)
|
26
|
+
client.lrange(key.to_s, start - 1, finish - 1)
|
27
|
+
end
|
28
|
+
|
29
|
+
def all(key)
|
30
|
+
client.lrange(key.to_s, 0, -1)
|
31
|
+
end
|
32
|
+
|
33
|
+
def count(key)
|
34
|
+
client.llen(key.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def create(key, value, order = :prepend)
|
38
|
+
if append?(order)
|
39
|
+
client.rpush(key.to_s, value)
|
40
|
+
else
|
41
|
+
client.lpush(key.to_s, value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def create!(key, value, order = :prepend)
|
46
|
+
if append?(order)
|
47
|
+
client.rpushx(key.to_s, value)
|
48
|
+
else
|
49
|
+
client.lpushx(key.to_s, value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_limit(key, value, limit, order = :prepend)
|
54
|
+
if append?(order)
|
55
|
+
client.rpush(key.to_s, value)
|
56
|
+
else
|
57
|
+
client.lpush(key.to_s, value)
|
58
|
+
end
|
59
|
+
|
60
|
+
client.ltrim(key.to_s, 0, limit - 1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_limit!(key, value, limit, order = :prepend)
|
64
|
+
if append?(order)
|
65
|
+
client.rpushx(key.to_s, value)
|
66
|
+
else
|
67
|
+
client.lpushx(key.to_s, value)
|
68
|
+
end
|
69
|
+
|
70
|
+
client.ltrim(key.to_s, 0, limit - 1)
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_before(key, pivot, value)
|
74
|
+
client.linsert(key.to_s, :before, pivot, value)
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_after(key, pivot, value)
|
78
|
+
client.linsert(key.to_s, :after, pivot, value)
|
79
|
+
end
|
80
|
+
|
81
|
+
def update(key, index, value)
|
82
|
+
client.lset(key.to_s, index, value)
|
83
|
+
end
|
84
|
+
|
85
|
+
def move(key, desination)
|
86
|
+
client.rpoplpush(key.to_s, desination.to_s)
|
87
|
+
end
|
88
|
+
|
89
|
+
def move_blocking(key, desination)
|
90
|
+
brpoplpush(key.to_s, desination.to_s)
|
91
|
+
end
|
92
|
+
|
93
|
+
def destroy(key, count, value)
|
94
|
+
client.lrem(key.to_s, count, value)
|
95
|
+
end
|
96
|
+
|
97
|
+
def destroy_first(key, limit = 1)
|
98
|
+
client.ltrim(key.to_s, limit, -1)
|
99
|
+
end
|
100
|
+
|
101
|
+
def destroy_last(key, limit = 1)
|
102
|
+
client.ltrim(key.to_s, 0, -(limit + 1))
|
103
|
+
end
|
104
|
+
|
105
|
+
def destroy_except(key, start, finish)
|
106
|
+
client.ltrim(key.to_s, start - 1, finish - 1)
|
107
|
+
end
|
108
|
+
|
109
|
+
def destroy_all(key)
|
110
|
+
client.ltrim(key.to_s, -1, 0)
|
111
|
+
end
|
112
|
+
|
113
|
+
def pop(key, order = :prepend)
|
114
|
+
if append?(order)
|
115
|
+
client.rpop(key)
|
116
|
+
else
|
117
|
+
client.lpop(key)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def pop_blocking(keys, opts = {})
|
122
|
+
timeout = opts[:timeout] || 0
|
123
|
+
|
124
|
+
if append?(opts[:order] || :prepend)
|
125
|
+
client.brpop(keys, timeout)
|
126
|
+
else
|
127
|
+
client.blpop(keys, timeout)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module PubSubHelper
|
6
|
+
|
7
|
+
def publish(channel, message)
|
8
|
+
client.publish(channel, message)
|
9
|
+
end
|
10
|
+
|
11
|
+
def subscribed?
|
12
|
+
client.subscribed?
|
13
|
+
end
|
14
|
+
|
15
|
+
def subscribe(*channels, timeout: nil, &block)
|
16
|
+
if timeout.nil?
|
17
|
+
client.subscribe(*channels, &block)
|
18
|
+
else
|
19
|
+
client.subscribe_with_timeout(timeout, *channels, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def unsubscribe(*channels)
|
24
|
+
client.unsubscribe(*channels)
|
25
|
+
end
|
26
|
+
|
27
|
+
def match_subscribe(*channels, timeout: nil, &block)
|
28
|
+
if timeout.nil?
|
29
|
+
client.psubscribe(*channels, &block)
|
30
|
+
else
|
31
|
+
client.psubscribe_with_timeout(timeout, *channels, &block)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def match_unsubscribe(*channels)
|
36
|
+
client.punsubscribe(*channels)
|
37
|
+
end
|
38
|
+
|
39
|
+
def state(command, *args)
|
40
|
+
client.pubsub(command, *args)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lite
|
4
|
+
module Redis
|
5
|
+
module ScriptHelper
|
6
|
+
|
7
|
+
def script(command, *args)
|
8
|
+
client.script(command, *args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def eval(*args)
|
12
|
+
client.eval(:eval, *args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def evalsha(*args)
|
16
|
+
client.eval(:evalsha, *args)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|