module ArCache
TODO
Constants
- PLACEHOLDER
- VERSION
Public Class Methods
cache_reflection?(reflection) { || ... }
click to toggle source
# File lib/ar_cache.rb, line 58 def cache_reflection?(reflection) @cache_reflection.fetch(reflection) do Thread.current[:ar_cache_reflection] = true @cache_reflection[reflection] = yield ensure Thread.current[:ar_cache_reflection] = false end end
dump_attributes(attributes)
click to toggle source
# File lib/ar_cache.rb, line 67 def dump_attributes(attributes) memcached? || redis? ? Oj.dump(attributes) : attributes end
load_attributes(attributes)
click to toggle source
# File lib/ar_cache.rb, line 71 def load_attributes(attributes) memcached? || redis? ? Oj.load(attributes) : attributes end
lock_key(key)
click to toggle source
# File lib/ar_cache.rb, line 75 def lock_key(key) ArCache.write(key, PLACEHOLDER, raw: true, expires_in: 1.hour) end
skip_cache() { || ... }
click to toggle source
# File lib/ar_cache.rb, line 32 def skip_cache return yield if skip_cache? begin Thread.current[:ar_cache_skip_cache] = true yield ensure Thread.current[:ar_cache_skip_cache] = false end end
skip_cache?()
click to toggle source
# File lib/ar_cache.rb, line 28 def skip_cache? Thread.current[:ar_cache_skip_cache] end
skip_expire() { || ... }
click to toggle source
# File lib/ar_cache.rb, line 47 def skip_expire return yield if skip_expire? begin Thread.current[:ar_cache_skip_expire] = true yield ensure Thread.current[:ar_cache_skip_expire] = false end end
skip_expire?()
click to toggle source
# File lib/ar_cache.rb, line 43 def skip_expire? Thread.current[:ar_cache_skip_expire] end