Class: Familia::String

Inherits:
RedisObject show all
Defined in:
lib/familia/redisobject.rb

Instance Attribute Summary

Attributes inherited from RedisObject

#cache, #name, #opts, #parent, #redis

Instance Method Summary collapse

Methods inherited from RedisObject

#class?, #clear_cache, #db, #delete, #dump_method, #echo, #exists?, #expire, #expireat, #from_redis, inherited, #initialize, #load_method, #move, #multi_from_redis, #parent?, #persist, #qstamp, #realttl, #rediskey, register, registration, #rename, #renamenx, #to_redis, #ttl, #type, #update_expiration

Constructor Details

This class inherits a constructor from Familia::RedisObject

Instance Method Details

#append(v) ⇒ Object Also known as: <<



970
971
972
973
974
# File 'lib/familia/redisobject.rb', line 970

def append v
  ret = redis.append rediskey, v
  update_expiration
  ret
end

#decrementObject Also known as: decr



956
957
958
959
960
# File 'lib/familia/redisobject.rb', line 956

def decrement
  ret = redis.decr rediskey
  update_expiration
  ret
end

#decrementby(int) ⇒ Object Also known as: decrby



963
964
965
966
967
# File 'lib/familia/redisobject.rb', line 963

def decrementby int
  ret = redis.decrby rediskey, int.to_i
  update_expiration
  ret
end

#empty?Boolean

Returns:

  • (Boolean)


908
909
910
# File 'lib/familia/redisobject.rb', line 908

def empty?
  size == 0
end

#getbit(offset) ⇒ Object



977
978
979
# File 'lib/familia/redisobject.rb', line 977

def getbit offset
  redis.getbit rediskey, offset
end

#getrange(spoint, epoint) ⇒ Object



987
988
989
# File 'lib/familia/redisobject.rb', line 987

def getrange spoint, epoint
  redis.getrange rediskey, spoint, epoint
end

#getset(v) ⇒ Object



997
998
999
1000
1001
# File 'lib/familia/redisobject.rb', line 997

def getset v
  ret = redis.getset rediskey, v
  update_expiration
  ret
end

#incrementObject Also known as: incr



942
943
944
945
946
# File 'lib/familia/redisobject.rb', line 942

def increment
  ret = redis.incr rediskey
  update_expiration
  ret
end

#incrementby(int) ⇒ Object Also known as: incrby



949
950
951
952
953
# File 'lib/familia/redisobject.rb', line 949

def incrementby int
  ret = redis.incrby rediskey, int.to_i
  update_expiration
  ret
end

#initObject



900
901
# File 'lib/familia/redisobject.rb', line 900

def init
end

#nil?Boolean

Returns:

  • (Boolean)


1003
1004
1005
# File 'lib/familia/redisobject.rb', line 1003

def nil?
  value.nil?
end

#setbit(offset, v) ⇒ Object



981
982
983
984
985
# File 'lib/familia/redisobject.rb', line 981

def setbit offset, v
  ret = redis.setbit rediskey, offset, v
  update_expiration
  ret
end

#setnx(v) ⇒ Object



936
937
938
939
940
# File 'lib/familia/redisobject.rb', line 936

def setnx v
  ret = redis.setnx rediskey, to_redis(v)
  update_expiration
  ret
end

#setrange(offset, v) ⇒ Object



991
992
993
994
995
# File 'lib/familia/redisobject.rb', line 991

def setrange offset, v
  ret = redis.setrange rediskey, offset, v
  update_expiration
  ret
end

#sizeObject Also known as: length



903
904
905
# File 'lib/familia/redisobject.rb', line 903

def size
  to_s.size
end

#to_iObject



924
925
926
# File 'lib/familia/redisobject.rb', line 924

def to_i
  value.to_i
end

#to_sObject



920
921
922
# File 'lib/familia/redisobject.rb', line 920

def to_s
  value.to_s  # value can return nil which to_s should not
end

#valueObject Also known as: content, get



912
913
914
915
916
# File 'lib/familia/redisobject.rb', line 912

def value
  echo :value, caller[0..5] if Familia.debug
  redis.setnx rediskey, @opts[:default] if @opts[:default]
  from_redis redis.get(rediskey)
end

#value=(v) ⇒ Object Also known as: replace, set



928
929
930
931
932
# File 'lib/familia/redisobject.rb', line 928

def value= v
  ret = redis.set rediskey, to_redis(v)
  update_expiration
  ret
end