Class: Familia::StringKey
- Defined in:
- lib/familia/data_type/types/stringkey.rb
Instance Attribute Summary collapse
-
#features_enabled ⇒ Object
included
from Features
readonly
Returns the value of attribute features_enabled.
- #logical_database(val = nil) ⇒ Object included from DataType::ClassMethods
-
#parent ⇒ Object
included
from DataType::ClassMethods
Returns the value of attribute parent.
-
#prefix ⇒ Object
included
from DataType::ClassMethods
Returns the value of attribute prefix.
-
#suffix ⇒ Object
included
from DataType::ClassMethods
Returns the value of attribute suffix.
-
#uri(val = nil) ⇒ Object
included
from DataType::ClassMethods
Returns the value of attribute uri.
Attributes included from Settings
#current_key_version, #default_expiration, #delim, #encryption_keys, #encryption_personalization, #logical_database, #prefix, #suffix, #transaction_mode
Instance Method Summary collapse
- #append(val) ⇒ Object (also: #<<)
-
#char_count ⇒ Integer
(also: #size, #length)
Returns the number of elements in the list.
- #decrement ⇒ Object (also: #decr)
- #decrementby(val) ⇒ Object (also: #decrby)
- #del ⇒ Object
- #empty? ⇒ Boolean
- #getbit(offset) ⇒ Object
- #getrange(spoint, epoint) ⇒ Object
- #getset(val) ⇒ Object
- #increment ⇒ Object (also: #incr)
- #incrementby(val) ⇒ Object (also: #incrby)
- #init ⇒ Object
- #setbit(offset, val) ⇒ Object
- #setnx(val) ⇒ Object
- #setrange(offset, val) ⇒ Object
- #to_i ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object (also: #content, #get)
- #value=(val) ⇒ Object (also: #replace, #set)
Methods included from Features::Autoloader
autoload_files, included, normalize_to_config_name
Methods included from DataType::Serialization
#deserialize_value, #deserialize_values, #deserialize_values_with_nil, #serialize_value
Methods included from DataType::DatabaseCommands
#current_expiration, #delete!, #echo, #exists?, #expire, #expireat, #move, #persist, #rename, #renamenx, #type
Methods included from DataType::Connection
#dbclient, #dbkey, #direct_access, #uri
Methods included from Connection::Behavior
#connect, #create_dbclient, #multi, #normalize_uri, #pipeline, #pipelined, #transaction, #uri=, #url, #url=
Methods included from Settings
#configure, #default_suffix, #pipelined_mode, #pipelined_mode=
Methods included from Base
add_feature, #as_json, #expired?, #expires?, find_feature, #generate_id, #to_json, #ttl, #update_expiration, #uuid
Constructor Details
This class inherits a constructor from Familia::DataType
Instance Attribute Details
#features_enabled ⇒ Object (readonly) Originally defined in module Features
Returns the value of attribute features_enabled.
#logical_database(val = nil) ⇒ Object Originally defined in module DataType::ClassMethods
#parent ⇒ Object Originally defined in module DataType::ClassMethods
Returns the value of attribute parent.
#prefix ⇒ Object Originally defined in module DataType::ClassMethods
Returns the value of attribute prefix.
#suffix ⇒ Object Originally defined in module DataType::ClassMethods
Returns the value of attribute suffix.
#uri(val = nil) ⇒ Object Originally defined in module DataType::ClassMethods
Returns the value of attribute uri.
Instance Method Details
#append(val) ⇒ Object Also known as: <<
81 82 83 84 85 |
# File 'lib/familia/data_type/types/stringkey.rb', line 81 def append(val) ret = dbclient.append dbkey, val update_expiration ret end |
#char_count ⇒ Integer Also known as: size, length
Returns the number of elements in the list
11 12 13 |
# File 'lib/familia/data_type/types/stringkey.rb', line 11 def char_count to_s.size end |
#decrement ⇒ Object Also known as: decr
67 68 69 70 71 |
# File 'lib/familia/data_type/types/stringkey.rb', line 67 def decrement ret = dbclient.decr dbkey update_expiration ret end |
#decrementby(val) ⇒ Object Also known as: decrby
74 75 76 77 78 |
# File 'lib/familia/data_type/types/stringkey.rb', line 74 def decrementby(val) ret = dbclient.decrby dbkey, val.to_i update_expiration ret end |
#del ⇒ Object
114 115 116 117 |
# File 'lib/familia/data_type/types/stringkey.rb', line 114 def del ret = dbclient.del dbkey ret.positive? end |
#empty? ⇒ Boolean
17 18 19 |
# File 'lib/familia/data_type/types/stringkey.rb', line 17 def empty? char_count.zero? end |
#getbit(offset) ⇒ Object
88 89 90 |
# File 'lib/familia/data_type/types/stringkey.rb', line 88 def getbit(offset) dbclient.getbit dbkey, offset end |
#getrange(spoint, epoint) ⇒ Object
98 99 100 |
# File 'lib/familia/data_type/types/stringkey.rb', line 98 def getrange(spoint, epoint) dbclient.getrange dbkey, spoint, epoint end |
#getset(val) ⇒ Object
108 109 110 111 112 |
# File 'lib/familia/data_type/types/stringkey.rb', line 108 def getset(val) ret = dbclient.getset dbkey, val update_expiration ret end |
#increment ⇒ Object Also known as: incr
53 54 55 56 57 |
# File 'lib/familia/data_type/types/stringkey.rb', line 53 def increment ret = dbclient.incr(dbkey) update_expiration ret end |
#incrementby(val) ⇒ Object Also known as: incrby
60 61 62 63 64 |
# File 'lib/familia/data_type/types/stringkey.rb', line 60 def incrementby(val) ret = dbclient.incrby(dbkey, val.to_i) update_expiration ret end |
#init ⇒ Object
7 |
# File 'lib/familia/data_type/types/stringkey.rb', line 7 def init; end |
#setbit(offset, val) ⇒ Object
92 93 94 95 96 |
# File 'lib/familia/data_type/types/stringkey.rb', line 92 def setbit(offset, val) ret = dbclient.setbit dbkey, offset, val update_expiration ret end |
#setnx(val) ⇒ Object
47 48 49 50 51 |
# File 'lib/familia/data_type/types/stringkey.rb', line 47 def setnx(val) ret = dbclient.setnx(dbkey, serialize_value(val)) update_expiration ret end |
#setrange(offset, val) ⇒ Object
102 103 104 105 106 |
# File 'lib/familia/data_type/types/stringkey.rb', line 102 def setrange(offset, val) ret = dbclient.setrange dbkey, offset, val update_expiration ret end |
#to_i ⇒ Object
35 36 37 |
# File 'lib/familia/data_type/types/stringkey.rb', line 35 def to_i value.to_i end |
#to_s ⇒ Object
29 30 31 32 33 |
# File 'lib/familia/data_type/types/stringkey.rb', line 29 def to_s return super if value.to_s.empty? value.to_s end |
#value ⇒ Object Also known as: content, get
21 22 23 24 25 |
# File 'lib/familia/data_type/types/stringkey.rb', line 21 def value echo :value, Familia.pretty_stack(limit: 1) if Familia.debug dbclient.setnx dbkey, @opts[:default] if @opts[:default] deserialize_value dbclient.get(dbkey) end |
#value=(val) ⇒ Object Also known as: replace, set
39 40 41 42 43 |
# File 'lib/familia/data_type/types/stringkey.rb', line 39 def value=(val) ret = dbclient.set(dbkey, serialize_value(val)) update_expiration ret end |