Class: Aerospike::Key
- Inherits:
-
Object
- Object
- Aerospike::Key
- Defined in:
- lib/aerospike/key.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#set_name ⇒ Object
readonly
Returns the value of attribute set_name.
-
#v1_compatible ⇒ Object
(also: #v1_compatible?)
readonly
Returns the value of attribute v1_compatible.
Class Method Summary collapse
-
.enable_v1_compatibility!(comp = true) ⇒ Object
enable backwards compatibility with v1 client for integer keys ref.
- .v1_compatible? ⇒ Boolean
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(ns, set, val, digest = nil, v1_compatible: self.class.v1_compatible?) ⇒ Key
constructor
A new instance of Key.
- #to_s ⇒ Object
- #user_key ⇒ Object
- #user_key_as_value ⇒ Object
Constructor Details
#initialize(ns, set, val, digest = nil, v1_compatible: self.class.v1_compatible?) ⇒ Key
Returns a new instance of Key.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aerospike/key.rb', line 48 def initialize(ns, set, val, digest=nil, v1_compatible: self.class.v1_compatible?) @namespace = ns @set_name = set @user_key = Value.of(val) @v1_compatible = v1_compatible unless digest compute_digest else @digest = digest end self end |
Instance Attribute Details
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
44 45 46 |
# File 'lib/aerospike/key.rb', line 44 def digest @digest end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
44 45 46 |
# File 'lib/aerospike/key.rb', line 44 def namespace @namespace end |
#set_name ⇒ Object (readonly)
Returns the value of attribute set_name.
44 45 46 |
# File 'lib/aerospike/key.rb', line 44 def set_name @set_name end |
#v1_compatible ⇒ Object (readonly) Also known as: v1_compatible?
Returns the value of attribute v1_compatible.
45 46 47 |
# File 'lib/aerospike/key.rb', line 45 def v1_compatible @v1_compatible end |
Class Method Details
.enable_v1_compatibility!(comp = true) ⇒ Object
enable backwards compatibility with v1 client for integer keys ref. github.com/aerospike/aerospike-client-ruby/pull/34
37 38 39 |
# File 'lib/aerospike/key.rb', line 37 def self.enable_v1_compatibility!(comp = true) @v1_compatibility = !!comp end |
.v1_compatible? ⇒ Boolean
40 41 42 |
# File 'lib/aerospike/key.rb', line 40 def self.v1_compatible? @v1_compatibility end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
76 77 78 79 80 |
# File 'lib/aerospike/key.rb', line 76 def ==(other) other && other.is_a?(Key) && other.digest == @digest && other.namespace == @namespace end |
#hash ⇒ Object
83 84 85 |
# File 'lib/aerospike/key.rb', line 83 def hash @digest.hash end |
#to_s ⇒ Object
64 65 66 |
# File 'lib/aerospike/key.rb', line 64 def to_s "#{@namespace}:#{@set_name}:#{@user_key}:#{@digest.nil? ? '' : @digest.bytes}" end |
#user_key ⇒ Object
68 69 70 |
# File 'lib/aerospike/key.rb', line 68 def user_key @user_key.get if @user_key end |
#user_key_as_value ⇒ Object
72 73 74 |
# File 'lib/aerospike/key.rb', line 72 def user_key_as_value @user_key end |