esse-redis_storage 0.0.2 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +5 -4
- data/lib/esse/redis_storage/queue.rb +7 -5
- data/lib/esse/redis_storage/version.rb +1 -1
- data/lib/esse/redis_storage.rb +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad734caa5a5772b8d7ba66bd2f40a031203b96edade5aa0547e5bf574c228094
|
4
|
+
data.tar.gz: 4efb7b6b025a32e69819f12902e97abc0fac887aaee7cf34082b8e6bcc77b50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e66697c37188316303ca3e9ce7466a3ae4a46255d33a75f6b4ed15c28b060cb7a3e1094b6bc2648238341becd6abb080175bcc0edf15d57e04b6fa8fcfd7ef6
|
7
|
+
data.tar.gz: 2e0991b872d1c15f07fd76398c0d52c01a934efada5a6b26ba1e04cfb7ecc3e66eb4e6362e011cfb39d8a3a385131a0d031ac7faeff5de2a83f28ea2493944e8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 0.1.1 - 2024-08-06
|
8
|
+
* Add TTL to the enqueued items in the queue.
|
9
|
+
* Included current time in the rand batch id to be more human readable.
|
10
|
+
|
11
|
+
## 0.1.0 - 2024-07-31
|
12
|
+
* Adjusting queue to allow to enqueue complex objects like Ruby hash and also preserve the primitive type.
|
13
|
+
|
7
14
|
## 0.0.2 - 2024-07-18
|
8
15
|
* The `Esse::RedisStorage::Queue.for` method now support both `repo:` and `attribute_name:` options.
|
9
16
|
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/marcosgz/esse.git
|
3
|
-
revision:
|
3
|
+
revision: 7d8fef8646a2f6acc3bfa475f351cfcd7d88fe17
|
4
4
|
branch: main
|
5
5
|
specs:
|
6
|
-
esse (0.
|
6
|
+
esse (0.3.4)
|
7
7
|
multi_json
|
8
8
|
thor (>= 0.19)
|
9
9
|
|
10
10
|
PATH
|
11
11
|
remote: .
|
12
12
|
specs:
|
13
|
-
esse-redis_storage (0.
|
14
|
-
esse (>= 0.2
|
13
|
+
esse-redis_storage (0.1.1)
|
14
|
+
esse (>= 0.3.2)
|
15
|
+
multi_json (>= 1.0.0)
|
15
16
|
redis (>= 4.0.0)
|
16
17
|
|
17
18
|
GEM
|
@@ -13,7 +13,7 @@ module Esse
|
|
13
13
|
attr_reader :name
|
14
14
|
|
15
15
|
def self.batch_id
|
16
|
-
SecureRandom.
|
16
|
+
String.new(Time.now.strftime("%Y%m%d%H%M%S%L-")) << SecureRandom.hex(4)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.for(repo:, attribute_name: nil)
|
@@ -28,12 +28,14 @@ module Esse
|
|
28
28
|
# Enqueue a batch of ids to process
|
29
29
|
# @param id [String] The batch id
|
30
30
|
# @param values [Array<String>] The values of the batch
|
31
|
-
def enqueue(id: nil, values: [])
|
31
|
+
def enqueue(id: nil, values: [], ttl: nil)
|
32
32
|
return if values.nil? || values.empty?
|
33
33
|
|
34
|
+
values = ::Esse::ArrayUtils.wrap(values)
|
34
35
|
batch_id = id || self.class.batch_id
|
35
36
|
with do |conn|
|
36
|
-
conn.hset(name, batch_id,
|
37
|
+
conn.hset(name, batch_id, ::MultiJson.dump(values))
|
38
|
+
conn.expire(name, ttl) if ttl
|
37
39
|
end
|
38
40
|
batch_id
|
39
41
|
end
|
@@ -46,7 +48,7 @@ module Esse
|
|
46
48
|
values = conn.hget(name, batch_id)
|
47
49
|
return unless values
|
48
50
|
|
49
|
-
yield
|
51
|
+
yield ::MultiJson.load(values)
|
50
52
|
conn.hdel(name, batch_id)
|
51
53
|
end
|
52
54
|
end
|
@@ -75,7 +77,7 @@ module Esse
|
|
75
77
|
def each
|
76
78
|
with do |conn|
|
77
79
|
conn.hscan_each(name, count: 1000) do |batch_id, values|
|
78
|
-
yield batch_id,
|
80
|
+
yield batch_id, ::MultiJson.load(values)
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
data/lib/esse/redis_storage.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esse-redis_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos G. Zimmermann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: esse
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2
|
19
|
+
version: 0.3.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2
|
26
|
+
version: 0.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: redis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: connection_pool
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|