foobara-redis-crud-driver 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/src/foobara/redis_crud_driver.rb +20 -36
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6c81dfe5009f3f778ec4f05b6bd0d6809718ba126fe0dba259c3666e344cd5
|
4
|
+
data.tar.gz: e30d4ff3154a4396106550c5ff8c46c00e160b62ec54ec8f93c74cb50d72d850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78efec1418b1fca8b349719f3fd4e7777f09460577bb9e1f12e38246a48f35cd65e1957f077c8e64147bbcd68c005c3a0fb9c12dc87d6711904b18863d7d4e55
|
7
|
+
data.tar.gz: 60547f0d67c390429179ad01a30e6338667ffe7cd6236fee88ae3bd061fa9ae9a5a3b36a221ccc11b435be29c15a6815134f276a967effebe0499bb2bf9a300f
|
data/CHANGELOG.md
CHANGED
@@ -38,22 +38,6 @@ module Foobara
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
# We don't make use of Redis transaction feature here because they are do not really work
|
42
|
-
# like database transactions which is what this feature is based on. We might want to use database transactions
|
43
|
-
# in some sort of flush feature though.
|
44
|
-
def open_transaction
|
45
|
-
# Should we have some kind of fake transaction object that raises errors when used after rolledback/closed?
|
46
|
-
Object.new
|
47
|
-
end
|
48
|
-
|
49
|
-
def close_transaction(_raw_tx)
|
50
|
-
end
|
51
|
-
|
52
|
-
def rollback_transaction(_raw_tx)
|
53
|
-
# nothing to do... except maybe enter a state where we don't flush anything else
|
54
|
-
# but can just rely on higher-up plumbing for that
|
55
|
-
end
|
56
|
-
|
57
41
|
class Table < Persistence::EntityAttributesCrudDriver::Table
|
58
42
|
def initialize(...)
|
59
43
|
super
|
@@ -67,30 +51,10 @@ module Foobara
|
|
67
51
|
end
|
68
52
|
end
|
69
53
|
|
70
|
-
def prefix
|
71
|
-
crud_driver.prefix
|
72
|
-
end
|
73
|
-
|
74
54
|
def get_id
|
75
55
|
redis.incr(sequence_key)
|
76
56
|
end
|
77
57
|
|
78
|
-
def sequence_key
|
79
|
-
@sequence_key ||= "#{entity_key_prefix}$sequence"
|
80
|
-
end
|
81
|
-
|
82
|
-
def primary_keys_index_key
|
83
|
-
@primary_keys_index_key ||= "#{entity_key_prefix}$all"
|
84
|
-
end
|
85
|
-
|
86
|
-
def entity_key_prefix
|
87
|
-
@entity_key_prefix ||= [*prefix, table_name].join(":")
|
88
|
-
end
|
89
|
-
|
90
|
-
def record_key_prefix(record_id)
|
91
|
-
"#{entity_key_prefix}:#{record_id}"
|
92
|
-
end
|
93
|
-
|
94
58
|
def all
|
95
59
|
Enumerator.new do |yielder|
|
96
60
|
batches_of_primary_keys.each do |batch|
|
@@ -198,6 +162,26 @@ module Foobara
|
|
198
162
|
|
199
163
|
private
|
200
164
|
|
165
|
+
def prefix
|
166
|
+
crud_driver.prefix
|
167
|
+
end
|
168
|
+
|
169
|
+
def sequence_key
|
170
|
+
@sequence_key ||= "#{entity_key_prefix}$sequence"
|
171
|
+
end
|
172
|
+
|
173
|
+
def primary_keys_index_key
|
174
|
+
@primary_keys_index_key ||= "#{entity_key_prefix}$all"
|
175
|
+
end
|
176
|
+
|
177
|
+
def entity_key_prefix
|
178
|
+
@entity_key_prefix ||= [*prefix, table_name].join(":")
|
179
|
+
end
|
180
|
+
|
181
|
+
def record_key_prefix(record_id)
|
182
|
+
"#{entity_key_prefix}:#{record_id}"
|
183
|
+
end
|
184
|
+
|
201
185
|
def redis
|
202
186
|
raw_connection
|
203
187
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-redis-crud-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foobara
|