Sha256: 8ee5394772a3813d1ed73e7b86825c5c627e9238bae86d8e2e13fbe68e3d34d3
Contents?: true
Size: 542 Bytes
Versions: 17
Compression:
Stored size: 542 Bytes
Contents
module IndexedCache def cache! all.count end private def cache_fetch return cache[:list] if cache[:list] cache[:list] = yield cache[:index] = prepare_index cache[:list] cache[:list] end def cache @cache ||= {} @cache[cache_key] ||= { index: nil, list: nil} end def cached_index cache[:index] end def cache_index(index) cache[:index] = index end def cache_key if __getobj__.respond_to? :cache_key __getobj__.send :cache_key else :default end end end
Version data entries
17 entries across 17 versions & 1 rubygems