Class: McCache
- Inherits:
-
Object
- Object
- McCache
- Defined in:
- lib/caches/mc_cache.rb
Class Method Summary collapse
- .client ⇒ Object
- .delete(key, options = {}) ⇒ Object
- .initialize ⇒ Object
-
.read(key, options = {}) ⇒ Object
Cache API, mimics ActiveSupport::Cache::Store api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html.
- .write(key, value, options = {}) ⇒ Object
Class Method Details
.client ⇒ Object
5 6 7 |
# File 'lib/caches/mc_cache.rb', line 5 def client @@client end |
.delete(key, options = {}) ⇒ Object
27 28 29 30 31 |
# File 'lib/caches/mc_cache.rb', line 27 def delete(key, = {}) deleted = read(key) client.delete(key) deleted end |
.initialize ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/caches/mc_cache.rb', line 9 def initialize config = ConfigService.load_config('memcached.yml')[ConfigService.environment] @@client ||= Dalli::Client.new(config['host'], config) rescue => error SdkLogger.logger.error("McCache.initialize error: #{error.message}") @@client = nil end |
.read(key, options = {}) ⇒ Object
Cache API, mimics ActiveSupport::Cache::Store api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html
19 20 21 |
# File 'lib/caches/mc_cache.rb', line 19 def read(key, = {}) client.get(key, ) end |
.write(key, value, options = {}) ⇒ Object
23 24 25 |
# File 'lib/caches/mc_cache.rb', line 23 def write(key, value, = {}) client.set(key, value, [:expires_in], ) end |