Sha256: 0a1dc5e1bb853664a26bb63514d238aacdb7bf5670e9449c3cd1329e312c584f
Contents?: true
Size: 435 Bytes
Versions: 15
Compression:
Stored size: 435 Bytes
Contents
module Ro class Cache < ::Map def write(key, value) invalidate(key) set(key => value) end def read(key, &block) if has?(key) get(key) else if block value = block.call write(key, value) else nil end end end def invalidate(key) prefix = Array(key).dup.tap{|array| array.pop} set(prefix, {}) end end end
Version data entries
15 entries across 15 versions & 1 rubygems