class Platform::Cache
Public Class Methods
cache()
click to toggle source
# File lib/platform/cache.rb, line 26 def self.cache @cache ||= begin if Platform::Config.cache_adapter == 'ActiveSupport::Cache' store_params = [Platform::Config.cache_store].flatten store_params[0] = store_params[0].to_sym ActiveSupport::Cache.lookup_store(*store_params) else eval(Platform::Config.cache_adapter) end end end
decrement(key, amount = 1)
click to toggle source
# File lib/platform/cache.rb, line 63 def self.decrement(key, amount = 1) return unless enabled? cache.decrement(versioned_key(key), amount) end
delete(key, options = nil)
click to toggle source
# File lib/platform/cache.rb, line 53 def self.delete(key, options = nil) return unless enabled? cache.delete(versioned_key(key), options) end
enabled?()
click to toggle source
# File lib/platform/cache.rb, line 38 def self.enabled? Platform::Config.enable_caching? end
fetch(key, options = {}) { || ... }
click to toggle source
# File lib/platform/cache.rb, line 46 def self.fetch(key, options = {}) return yield unless enabled? cache.fetch(versioned_key(key), options) do yield end end
get(key, options = {})
click to toggle source
# File lib/platform/cache.rb, line 73 def self.get(key, options = {}) return unless enabled? cache.get(key, options) end
increment(key, amount = 1)
click to toggle source
# File lib/platform/cache.rb, line 58 def self.increment(key, amount = 1) return unless enabled? cache.increment(versioned_key(key), amount) end
set(key, value, options = {})
click to toggle source
# File lib/platform/cache.rb, line 68 def self.set(key, value, options = {}) return unless enabled? cache.set(key, value, options) end
versioned_key(key)
click to toggle source
# File lib/platform/cache.rb, line 42 def self.versioned_key(key) "#{Platform::Config.cache_version}_#{key}" end