class Cachext::Key
Attributes
raw[R]
Public Class Methods
new(raw, config: Cachext.config)
click to toggle source
# File lib/cachext/key.rb, line 5 def initialize(raw, config: Cachext.config) @raw = Array(raw) @config = config end
Public Instance Methods
backup()
click to toggle source
# File lib/cachext/key.rb, line 18 def backup [:backup_cache] + raw end
clear()
click to toggle source
# File lib/cachext/key.rb, line 38 def clear cache.delete raw end
delete_backup()
click to toggle source
# File lib/cachext/key.rb, line 50 def delete_backup cache.delete backup end
digest()
click to toggle source
# File lib/cachext/key.rb, line 14 def digest ::Digest::SHA1.hexdigest ::Marshal.dump(raw) end
inspect()
click to toggle source
# File lib/cachext/key.rb, line 10 def inspect "#<Cachext::Key:#{object_id.to_s(16)} @raw=#{@raw.inspect} digest=#{digest}>" end
lock_key()
click to toggle source
# File lib/cachext/key.rb, line 22 def lock_key "cachext:lock:#{digest}" end
locked?()
click to toggle source
# File lib/cachext/key.rb, line 26 def locked? lock_redis.exists lock_key end
read()
click to toggle source
# File lib/cachext/key.rb, line 30 def read cache.read raw end
read_backup()
click to toggle source
# File lib/cachext/key.rb, line 42 def read_backup cache.read backup end
write(value, options = {})
click to toggle source
# File lib/cachext/key.rb, line 34 def write value, options = {} cache.write raw, value, options end
write_backup(value)
click to toggle source
# File lib/cachext/key.rb, line 46 def write_backup value cache.write backup, value end
Private Instance Methods
cache()
click to toggle source
# File lib/cachext/key.rb, line 56 def cache @config.cache end
lock_redis()
click to toggle source
# File lib/cachext/key.rb, line 60 def lock_redis @config.lock_redis end