Class: VK::VALUE

Inherits:
O
  • Object
show all
Defined in:
lib/valkey/objects.rb

Instance Attribute Summary

Attributes inherited from O

#key

Instance Method Summary collapse

Methods inherited from O

#delete!, #expire, #initialize

Constructor Details

This class inherits a constructor from VK::O

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)

363
364
365
# File 'lib/valkey/objects.rb', line 363

def exist?                                                                                                                                        
  VK.redis.call("GET", key) ? true : false                                                                                                        
end

#match(r, &b) ⇒ Object


366
367
368
369
370
371
372
373
# File 'lib/valkey/objects.rb', line 366

def match r, &b
  m = Regexp.new(r).match(value)
  if block_given?
    b.call(m)
  else
    return m
  end
end

#valueObject


353
354
355
356
357
358
359
# File 'lib/valkey/objects.rb', line 353

def value
  x = VK.redis.call("GET", key)
  if @opts.has_key?(:flush) == true
    delete!
  end
  return x
end

#value=(x) ⇒ Object


360
361
362
# File 'lib/valkey/objects.rb', line 360

def value= x
  VK.redis.call("SET", key, x)
end