valkey-objects 0.2.6 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1887be271a0106fe51ed5d9b512298e4a2a1f9b2439e3557b0a4d51864457b01
4
- data.tar.gz: 833053b9c7b76c043f7beae6528b393e69427b31c6ddc7c00c60b02d7d0ecd1f
3
+ metadata.gz: e91f9301c09a4ad135df31fe626a96d08280fc644b101376fa46b2e8681ffff1
4
+ data.tar.gz: fda897186e70bcc597a7ea99991fc683d245423bea3095bacb97978b27ddbb91
5
5
  SHA512:
6
- metadata.gz: e35d557b198817da02f4d78053215227a034172230f8d50ed34730d301208318cf95c04d41884fcff8b9b1815ac1dad854581f5f1b9dc72c0cfcf00317f38f27
7
- data.tar.gz: 5aaf1dcd68d832f0ec3ebd46e7f984cae5ed13c50cfa48feb6b2843a09de14f932775fd3388df527b902d48ef82ab4b79920a23ff37a2480cab133a2a20e59c8
6
+ metadata.gz: 050f363cfe1a8154a8fdac9ddd1ace13877643f873edf4b2ca6b89846e150b3774697f533d358bf124d829f4353176e5810fca60e6ab82ef05b9ce7fe711a72a
7
+ data.tar.gz: 3b3cb373c7a6db40795cc692c1f29ce582ae9eb37462914951896ebca8d50ac346b4170d9992787e0b2343ba9e7139e89aff0992dabd00d3080de46108fd8588
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Valkey
4
4
  module Objects
5
- VERSION = "0.2.6"
5
+ VERSION = "0.2.9"
6
6
  end
7
7
  end
@@ -2,16 +2,17 @@
2
2
 
3
3
  require_relative "objects/version"
4
4
 
5
+ require 'connection_pool'
5
6
  require 'redis-client'
6
7
  require 'json'
7
8
  require 'ruby-duration'
8
9
  require 'amatch'
9
10
  require 'ap'
11
+ require 'yaml'
12
+
10
13
  module VK
11
14
 
12
15
  @@XX = {}
13
-
14
-
15
16
 
16
17
  def self.included(x)
17
18
  x.extend VK
@@ -225,14 +226,17 @@ module VK
225
226
  end
226
227
 
227
228
  def self.redis
228
- RedisClient.config(host: "127.0.0.1", port: 6379, db: 0).new_client
229
+ @redis ||= ConnectionPool::Wrapper.new do
230
+ RedisClient.config(host: "127.0.0.1", port: 6379, db: 0).new_client
231
+ end
229
232
  end
230
233
 
231
234
  class O
232
235
  attr_reader :key
233
236
  def initialize k, h={}
234
237
  @key = k
235
- @opts = h
238
+ @opts = h
239
+ # puts %[VK #{@key} #{h}]
236
240
  if @opts.has_key?(:ttl)
237
241
  expire @opts[:ttl]
238
242
  end
@@ -243,16 +247,16 @@ module VK
243
247
  def expire sec
244
248
  VK.redis.call("EXPIRE", key, sec);
245
249
  end
246
- end
247
-
248
- class TIMESTAMP < O
249
250
  def value
250
251
  x = VK.redis.call("GET", key);
251
252
  if @opts.has_key?(:flush) == true
252
253
  delete!
253
254
  end
254
255
  return x
255
- end
256
+ end
257
+ end
258
+
259
+ class TIMESTAMP < O
256
260
  def value!
257
261
  VK.redis.call("SET", key, "#{VK.clock.to_i}");
258
262
  end
@@ -269,10 +273,11 @@ module VK
269
273
 
270
274
  class TOGGLE < O
271
275
  def value
272
- VK.redis.call("GET", key) == 'true' ? true : false
276
+ x = VK.redis.call("GET", key) == 'true' ? true : false
273
277
  if @opts.has_key?(:flush) == true
274
278
  delete!
275
279
  end
280
+ return x
276
281
  end
277
282
  def exist?
278
283
  VK.redis.call("GET", key) ? true : false
@@ -281,7 +286,7 @@ module VK
281
286
  VK.redis.call("SET", key, "#{x.to_s}")
282
287
  end
283
288
  def value!
284
- if self.value
289
+ if self.value == true || self.value == nil
285
290
  self.value = false
286
291
  else
287
292
  self.value = true
@@ -291,10 +296,11 @@ module VK
291
296
 
292
297
  class VALUE < O
293
298
  def value
294
- VK.redis.call("GET", key)
299
+ x = VK.redis.call("GET", key)
295
300
  if @opts.has_key?(:flush) == true
296
301
  delete!
297
302
  end
303
+ return x.to_f
298
304
  end
299
305
  def value= x
300
306
  VK.redis.call("SET", key, x)
@@ -360,22 +366,23 @@ module VK
360
366
 
361
367
  class COUNTER < O
362
368
  def incr n
363
- VK.redis.call("SET", key, value + n.to_f)
369
+ VK.redis.call("SET", @key, value + n.to_f)
364
370
  end
365
371
  def decr n
366
- VK.redis.call("SET", key, value + n.to_f)
372
+ VK.redis.call("SET", @key, value + n.to_f)
367
373
  end
368
374
  def value
369
- VK.redis.call("GET", key).to_f
375
+ x = VK.redis.call("GET", @key).to_f
370
376
  if @opts.has_key?(:flush) == true
371
377
  delete!
372
- end
378
+ end
379
+ return x
373
380
  end
374
381
  def value= n
375
- VK.redis.call("SET", key, n.to_f)
382
+ VK.redis.call("SET", @key, n.to_f)
376
383
  end
377
384
  def exist?
378
- VK.redis.call("GET", key) ? true : false
385
+ VK.redis.call("GET", @key) ? true : false
379
386
  end
380
387
  end
381
388
 
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.2.6
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-13 00:00:00.000000000 Z
11
+ date: 2025-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client