Module: VK

Defined in:
lib/valkey/objects.rb

Defined Under Namespace

Modules: AGO Classes: B, C, G, H, O, P, Q, S, T, V

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](k) ⇒ Object



235
236
237
# File 'lib/valkey/objects.rb', line 235

def self.[] k
  VK.redis.call("KEYS", k)
end

.clock(*t) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/valkey/objects.rb', line 59

def self.clock *t
  if t[0]
    AGO[t[0]]
  else
    AGO.now
  end
end

.extended(x) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/valkey/objects.rb', line 14

def self.extended(x)
  xx = x.name.gsub("::", "-")
  define_method(:value) { |k| define_method(k.to_sym) { V.new(%[#{xx}:value:#{k}:#{@id}]) } };
  define_method(:counter) { |k| define_method(k.to_sym) { C.new(%[#{xx}:counter:#{k}:#{@id}]); } };
  define_method(:hashkey) { |k| define_method(k.to_sym) { H.new(%[#{xx}:hash:#{k}:#{@id}]); } };
  define_method(:sortedset) { |k| define_method(k.to_sym) { S.new(%[#{xx}:sortedset:#{k}:#{@id}]); } };
  define_method(:set) { |k| define_method(k.to_sym) { G.new(%[#{xx}:set:#{k}:#{@id}]); } };
  define_method(:queue) { |k| define_method(k.to_sym) { Q.new(%[#{xx}:queue:#{k}:#{@id}]); } };
  define_method(:place) { |k| define_method(k.to_sym) { P.new(%[#{xx}:place:#{k}:#{@id}]); } };
  define_method(:pipe) { |k| define_method(k.to_sym) { B.new(%[#{xx}:pipe:#{k}:#{@id}]); } };
  define_method(:toggle) { |k| define_method(k.to_sym) { T.new(%[#{xx}:toggle:#{k}:#{@id}]); } };
end

.flushdb!Object



232
233
234
# File 'lib/valkey/objects.rb', line 232

def self.flushdb!
  VK.redis.call("FLUSHDB")
end

.included(x) ⇒ Object



10
11
12
# File 'lib/valkey/objects.rb', line 10

def self.included(x)
  x.extend VK
end

.redisObject



67
68
69
# File 'lib/valkey/objects.rb', line 67

def self.redis
  RedisClient.config(host: "127.0.0.1", port: 6379, db: 0).new_client
end

Instance Method Details

#idObject



27
28
29
# File 'lib/valkey/objects.rb', line 27

def id
  @id
end