Class: CacheService
- Inherits:
-
Object
- Object
- CacheService
- Defined in:
- lib/services/cache_service.rb
Class Method Summary collapse
- .cache ⇒ Object
- .cache=(other_cache) ⇒ Object
- .delete(key, options = {}) ⇒ Object
- .initialize ⇒ Object
- .read(key, options = {}) ⇒ Object
- .write(key, value, options = {}) ⇒ Object
Class Method Details
.cache ⇒ Object
5 6 7 |
# File 'lib/services/cache_service.rb', line 5 def cache @@cache end |
.cache=(other_cache) ⇒ Object
9 10 11 |
# File 'lib/services/cache_service.rb', line 9 def cache=(other_cache) @@cache = other_cache end |
.delete(key, options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/services/cache_service.rb', line 34 def delete(key, = {}) return nil unless cache cache.delete(key, ) end |
.initialize ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/services/cache_service.rb', line 13 def initialize config = ConfigService.load_config('cache_config.yml')[ConfigService.environment] # Load all the existing caches in the system, outside of the gem Dir.glob("#{File.expand_path('.')}/caches/*.rb").each { |rb_file| require rb_file } @@cache ||= eval(config['cache']) SdkLogger.logger = eval(config['logger']) if config['logger'].present? rescue Exception => error puts("Error #{error.message}") @@cache = nil end |
.read(key, options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/services/cache_service.rb', line 24 def read(key, = {}) return nil unless cache cache.read(key, ) end |
.write(key, value, options = {}) ⇒ Object
29 30 31 32 |
# File 'lib/services/cache_service.rb', line 29 def write(key, value, = {}) return nil unless cache cache.write(key, value, ) end |