active_orm 4.0.3 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek +4 -10
- data/.rubocop.yml +0 -20
- data/Gemfile +2 -0
- data/README.md +0 -1
- data/Rakefile +2 -0
- data/active_orm.gemspec +2 -1
- data/bin/console +1 -0
- data/bin/rake +2 -2
- data/lib/active_orm.rb +9 -5
- data/lib/active_orm/railtie.rb +2 -0
- data/lib/active_orm/redis/base.rb +71 -60
- data/lib/active_orm/redis/configuration.rb +32 -5
- data/lib/active_orm/redis/connection.rb +77 -73
- data/lib/active_orm/redis/geo.rb +23 -19
- data/lib/active_orm/redis/hash.rb +61 -57
- data/lib/active_orm/redis/hyper_log_log.rb +14 -10
- data/lib/active_orm/redis/key.rb +70 -66
- data/lib/active_orm/redis/list.rb +125 -121
- data/lib/active_orm/redis/pub_sub.rb +26 -22
- data/lib/active_orm/redis/script.rb +14 -10
- data/lib/active_orm/redis/set.rb +55 -51
- data/lib/active_orm/redis/sorted_set.rb +150 -146
- data/lib/active_orm/redis/string.rb +75 -71
- data/lib/active_orm/redis/transaction.rb +20 -16
- data/lib/active_orm/version.rb +3 -1
- data/lib/generators/active_orm/install_generator.rb +2 -0
- data/lib/generators/active_orm/templates/install.rb +2 -0
- data/lib/tasks/redis.rake +2 -0
- metadata +3 -20
- data/.coveralls.yml +0 -1
- data/lib/active_orm/base.rb +0 -13
- data/lib/active_orm/redis.rb +0 -23
@@ -1,96 +1,100 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
value = metamorph(value) if evaluate?
|
6
|
-
value
|
7
|
-
end
|
3
|
+
class ActiveOrm::Redis::String < ActiveOrm::Redis::Base
|
4
|
+
class << self
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
6
|
+
def find(key)
|
7
|
+
value = client.get(normalize_key(key))
|
8
|
+
value = metamorph(value) if evaluate?
|
9
|
+
value
|
10
|
+
end
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
def find_each(*args)
|
13
|
+
args = stringify_keys(args)
|
14
|
+
value = client.mget(args)
|
15
|
+
value = metamorph(value) if evaluate?
|
16
|
+
value
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
def length(key)
|
20
|
+
client.strlen(normalize_key(key))
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
def split(key, start, finish)
|
24
|
+
client.getrange(normalize_key(key), start, finish)
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def create(key, value, opts = {})
|
28
|
+
client.set(normalize_key(key), value, opts)
|
29
|
+
end
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
31
|
+
def create!(key, value)
|
32
|
+
client.setnx(normalize_key(key), value)
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
def create_each(*args)
|
36
|
+
args = stringify_keys(args)
|
37
|
+
client.mset(args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_each!(*args)
|
41
|
+
args = stringify_keys(args)
|
42
|
+
client.msetnx(args)
|
43
|
+
end
|
41
44
|
|
42
|
-
|
43
|
-
|
45
|
+
def create_until(key, value, seconds, format = :seconds)
|
46
|
+
normalized_key = normalize_key(key)
|
44
47
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
48
|
+
if seconds?(format)
|
49
|
+
client.setex(normalized_key, seconds, value)
|
50
|
+
else
|
51
|
+
client.psetex(normalized_key, seconds, value)
|
52
|
+
end
|
49
53
|
end
|
50
|
-
end
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
def append(key, value)
|
56
|
+
client.append(normalize_key(key), value)
|
57
|
+
end
|
55
58
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
+
def replace(key, value, offset)
|
60
|
+
client.setrange(normalize_key(key), offset, value)
|
61
|
+
end
|
59
62
|
|
60
|
-
|
61
|
-
|
63
|
+
def decrement(key, value = 1)
|
64
|
+
normalized_key = normalize_key(key)
|
62
65
|
|
63
|
-
|
64
|
-
|
66
|
+
value == 1 ? client.decr(normalized_key) : client.decrby(normalized_key, value)
|
67
|
+
end
|
65
68
|
|
66
|
-
|
67
|
-
|
69
|
+
def increment(key, value = 1)
|
70
|
+
normalized_key = normalize_key(key)
|
68
71
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
if value.is_a?(Float)
|
73
|
+
client.incrbyfloat(normalized_key, value)
|
74
|
+
else
|
75
|
+
value == 1 ? client.incr(normalized_key) : client.incrby(normalized_key, value)
|
76
|
+
end
|
73
77
|
end
|
74
|
-
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
def reset(key, value = 0)
|
80
|
+
client.getset(normalize_key(key), value)
|
81
|
+
end
|
79
82
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
+
def bit_count(key, start = 0, finish = -1)
|
84
|
+
client.bitcount(normalize_key(key), start, finish)
|
85
|
+
end
|
83
86
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
+
def bit_where(operation, key, *keys)
|
88
|
+
client.bitop(operation, key, *keys)
|
89
|
+
end
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
+
def get_bit(key, offset)
|
92
|
+
client.getbit(normalize_key(key), offset)
|
93
|
+
end
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
def set_bit(key, offset, bit)
|
96
|
+
client.setbit(normalize_key(key), offset, bit)
|
97
|
+
end
|
95
98
|
|
99
|
+
end
|
96
100
|
end
|
@@ -1,23 +1,27 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
end
|
3
|
+
class ActiveOrm::Redis::Transaction < ActiveOrm::Redis::Base
|
4
|
+
class << self
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def discard
|
7
|
+
client.discard
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def exec
|
11
|
+
client.exec
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def multi(&block)
|
15
|
+
client.multi(&block)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def watch(*args)
|
19
|
+
client.watch(args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def unwatch
|
23
|
+
client.unwatch
|
24
|
+
end
|
22
25
|
|
26
|
+
end
|
23
27
|
end
|
data/lib/active_orm/version.rb
CHANGED
data/lib/tasks/redis.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-configurable
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,7 +144,6 @@ extensions: []
|
|
158
144
|
extra_rdoc_files: []
|
159
145
|
files:
|
160
146
|
- ".DS_Store"
|
161
|
-
- ".coveralls.yml"
|
162
147
|
- ".fasterer.yml"
|
163
148
|
- ".gitignore"
|
164
149
|
- ".reek"
|
@@ -176,9 +161,7 @@ files:
|
|
176
161
|
- lib/.DS_Store
|
177
162
|
- lib/active_orm.rb
|
178
163
|
- lib/active_orm/.DS_Store
|
179
|
-
- lib/active_orm/base.rb
|
180
164
|
- lib/active_orm/railtie.rb
|
181
|
-
- lib/active_orm/redis.rb
|
182
165
|
- lib/active_orm/redis/.DS_Store
|
183
166
|
- lib/active_orm/redis/base.rb
|
184
167
|
- lib/active_orm/redis/configuration.rb
|
@@ -218,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
201
|
version: '0'
|
219
202
|
requirements: []
|
220
203
|
rubyforge_project:
|
221
|
-
rubygems_version: 2.6.
|
204
|
+
rubygems_version: 2.6.13
|
222
205
|
signing_key:
|
223
206
|
specification_version: 4
|
224
207
|
summary: Gem for commonly used database ORM.
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|
data/lib/active_orm/base.rb
DELETED
data/lib/active_orm/redis.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'fakeredis'
|
3
|
-
rescue LoadError
|
4
|
-
require 'redis'
|
5
|
-
end
|
6
|
-
|
7
|
-
require 'active_orm/redis/base'
|
8
|
-
require 'active_orm/redis/configuration'
|
9
|
-
|
10
|
-
class ActiveOrm::Redis < ActiveOrm::Base
|
11
|
-
extend Base
|
12
|
-
|
13
|
-
attr_accessor :client
|
14
|
-
|
15
|
-
def initialize(client = nil)
|
16
|
-
@client ||= (client.nil? ? ActiveOrm::Redis.configuration.client : client)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.client(client = nil)
|
20
|
-
client.nil? ? new.client : new(client).client
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|