valkey-objects 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/valkey/objects/version.rb +1 -1
- data/lib/valkey/objects.rb +100 -4
- data/valkey-objects-0.1.1.gem +0 -0
- data/valkey-objects.gemspec +0 -1
- metadata +3 -17
- data/.#class.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0a9c6aca1b5339587ab8d14cba5dee0fa05f0ffdb3460fd349282d384c76038
|
4
|
+
data.tar.gz: 4d542d22a756ae8ce4dff600aae73f6f9a4cc41deb0db7abe91b6395a042fb02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50cff3351928a9b7f66f871f9fdab25f65646e7b4978eb981f1e9671babe40472e95a1d8e5c8121aa285cc64fb6148ee8488af852b8de9b87ed17338274e1bbc
|
7
|
+
data.tar.gz: e823ed4e7c79546888de0e527384fb02860c992b8ac5ad8c09072ba9ba9d461c312cb64dfc7867a60dda0aca55ca0aee889a6fc0e1c5db2db222da5da403be9a
|
data/lib/valkey/objects.rb
CHANGED
@@ -12,15 +12,105 @@ module VK
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.extended(x)
|
15
|
+
##
|
16
|
+
# Example:
|
17
|
+
# class ExmpleObject
|
18
|
+
# include VK
|
19
|
+
# value :myValue
|
20
|
+
# counter :myCounter
|
21
|
+
# hashkey :myHashKey
|
22
|
+
# sortedset :mySortedSet
|
23
|
+
# set :mySet
|
24
|
+
# queue :myQueue
|
25
|
+
# place :myPlace
|
26
|
+
# pipe :myPipe
|
27
|
+
# toggle :myToggle
|
28
|
+
# def initialize k
|
29
|
+
# @id = k
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# Instantiation: @obj = ExampleObject.new('object id...')
|
15
34
|
xx = x.name.gsub("::", "-")
|
35
|
+
##
|
36
|
+
# value :myValue
|
37
|
+
# @obj.myValue => A string
|
38
|
+
# @obj.myValue.value = "my value"
|
39
|
+
# @obj.myValue.value => "my value"
|
16
40
|
define_method(:value) { |k| define_method(k.to_sym) { V.new(%[#{xx}:value:#{k}:#{@id}]) } };
|
41
|
+
##
|
42
|
+
# counter :myCounter => A number
|
43
|
+
# @obj.myCounter
|
44
|
+
# @obj.myCounter.value = number
|
45
|
+
# @obj.myCounter.value => ...
|
46
|
+
# @obj.myCounter.incr number
|
47
|
+
# @obj.myCounter.decr number
|
48
|
+
#
|
17
49
|
define_method(:counter) { |k| define_method(k.to_sym) { C.new(%[#{xx}:counter:#{k}:#{@id}]); } };
|
50
|
+
##
|
51
|
+
#
|
52
|
+
define_method(:timestamp) { |k| define_method(k.to_sym) { N.new(%[#{xx}:counter:#{k}:#{@id}]) } }
|
53
|
+
##
|
54
|
+
# hashkey :myHashKey => The ubiquitous Ruby Hash in valkey/redis
|
55
|
+
# @obj.myHashKey
|
56
|
+
# @obj.myHashKey[:key] = value
|
57
|
+
# @obj.myHashKey[:key] => ...
|
58
|
+
#
|
18
59
|
define_method(:hashkey) { |k| define_method(k.to_sym) { H.new(%[#{xx}:hash:#{k}:#{@id}]); } };
|
60
|
+
##
|
61
|
+
# sortedset :mySortedSet => A ranked collection of members
|
62
|
+
# @obj.mySortedSet
|
63
|
+
# @obj.mySortedSet[:key] = value
|
64
|
+
# @obj.mySortedSet[:key] => ...
|
65
|
+
# @obj.mySortedSet.value { |key, i| ... }
|
66
|
+
# @obj.mySortedSet.poke key, number
|
67
|
+
#
|
19
68
|
define_method(:sortedset) { |k| define_method(k.to_sym) { S.new(%[#{xx}:sortedset:#{k}:#{@id}]); } };
|
69
|
+
##
|
70
|
+
# set :mySet => A collect of unique members
|
71
|
+
# @obj.mySet
|
72
|
+
# @obj.mySet << "x"
|
73
|
+
# @obj.myset.rm "x"
|
74
|
+
# @obj.mySet & @obj.otherSet
|
75
|
+
# @obj.mySet | @obj.otherSet
|
76
|
+
# @obj.myset["pattern"]
|
77
|
+
# @obj.mySet.value { |key, i| ... }
|
78
|
+
#
|
20
79
|
define_method(:set) { |k| define_method(k.to_sym) { G.new(%[#{xx}:set:#{k}:#{@id}]); } };
|
80
|
+
##
|
81
|
+
# queue :myQueue => An array with push and pop utility
|
82
|
+
# @obj.myQueue
|
83
|
+
# @obj.myQueue << "x"
|
84
|
+
# @obj.myQueue.front => "x" and pop
|
85
|
+
# @obj.myQueue.value { |key, i| ... }
|
86
|
+
#
|
21
87
|
define_method(:queue) { |k| define_method(k.to_sym) { Q.new(%[#{xx}:queue:#{k}:#{@id}]); } };
|
88
|
+
##
|
89
|
+
# place :myPlace => GPS Coordinates
|
90
|
+
# @obj.myPlace
|
91
|
+
# @obj.myPlace.add "key", longitude, latitude
|
92
|
+
# @obj.myPlace["key"] => { longitude: xx, latitude: yy }
|
93
|
+
# @obj.myPlace.distance "key", "other key"
|
94
|
+
# @obj.myPlace.radius longitude, latitude, distance
|
95
|
+
# @obj.myPlace.value { |key, i| ... }
|
96
|
+
#
|
22
97
|
define_method(:place) { |k| define_method(k.to_sym) { P.new(%[#{xx}:place:#{k}:#{@id}]); } };
|
98
|
+
##
|
99
|
+
# pipe :myPipe => Subscibe and handle, and publish.
|
100
|
+
# @obj.myPipe
|
101
|
+
# @obj.myPipe.on { |msg| ... }
|
102
|
+
# @obj.myPipe << "input" => publish { input: "input" }
|
103
|
+
# @obj.myPipe << ["input","input"] => publish { inputs: ["input", "input"] }
|
104
|
+
# @obj.myPipe << {} => publish {}
|
105
|
+
#
|
23
106
|
define_method(:pipe) { |k| define_method(k.to_sym) { B.new(%[#{xx}:pipe:#{k}:#{@id}]); } };
|
107
|
+
##
|
108
|
+
# toggle :myToggle => Boolean toggle.
|
109
|
+
# @obj.myToggle
|
110
|
+
# @obj.value = bool
|
111
|
+
# @obj.value => ...
|
112
|
+
# @obj.value! => value = !value
|
113
|
+
#
|
24
114
|
define_method(:toggle) { |k| define_method(k.to_sym) { T.new(%[#{xx}:toggle:#{k}:#{@id}]); } };
|
25
115
|
end
|
26
116
|
|
@@ -75,6 +165,15 @@ module VK
|
|
75
165
|
end
|
76
166
|
end
|
77
167
|
|
168
|
+
class N < O
|
169
|
+
def value
|
170
|
+
VK.redis.call("GET", key).to_i;
|
171
|
+
end
|
172
|
+
def value!
|
173
|
+
VK.redis.call("SET", key, "#{VK.clock.to_i}");
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
78
177
|
class T < O
|
79
178
|
def value
|
80
179
|
VK.redis.call("GET", key) == 'true' ? true : false
|
@@ -155,7 +254,7 @@ module VK
|
|
155
254
|
|
156
255
|
class Q < O
|
157
256
|
def value &b
|
158
|
-
VK.redis.call("LRANGE", key, 0, -1
|
257
|
+
VK.redis.call("LRANGE", key, 0, -1).each_with_index { |e, i| b.call(i, e) }
|
159
258
|
end
|
160
259
|
def length
|
161
260
|
VK.redis.call("LLEN", key)
|
@@ -237,6 +336,3 @@ module VK
|
|
237
336
|
end
|
238
337
|
end
|
239
338
|
|
240
|
-
|
241
|
-
|
242
|
-
|
Binary file
|
data/valkey-objects.gemspec
CHANGED
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
|
33
33
|
# Uncomment to register a new dependency of your gem
|
34
34
|
spec.add_dependency "redis-client"
|
35
|
-
spec.add_dependency "awesome_print"
|
36
35
|
spec.add_dependency "json"
|
37
36
|
spec.add_dependency "ruby-duration"
|
38
37
|
# For more information and examples about making a new gem, check out our
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valkey-objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Olson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: awesome_print
|
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: json
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,7 +60,6 @@ extensions: []
|
|
74
60
|
extra_rdoc_files: []
|
75
61
|
files:
|
76
62
|
- "#class.rb#"
|
77
|
-
- ".#class.rb"
|
78
63
|
- CHANGELOG.md
|
79
64
|
- CODE_OF_CONDUCT.md
|
80
65
|
- LICENSE.txt
|
@@ -87,6 +72,7 @@ files:
|
|
87
72
|
- module.rb~
|
88
73
|
- sig/valkey/objects.rbs
|
89
74
|
- valkey-objects-0.1.0.gem
|
75
|
+
- valkey-objects-0.1.1.gem
|
90
76
|
- valkey-objects.gemspec
|
91
77
|
homepage: https://github.com/xorgnak/valkey-client
|
92
78
|
licenses:
|
data/.#class.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
erik@z4-home.3169:1729306329
|