Class: ConfigCat::ManualPollingCachePolicy
- Inherits:
-
CachePolicy
- Object
- CachePolicy
- ConfigCat::ManualPollingCachePolicy
- Defined in:
- lib/configcat/manualpollingcachepolicy.rb
Instance Method Summary collapse
- #force_refresh ⇒ Object
- #get ⇒ Object
-
#initialize(config_fetcher, config_cache) ⇒ ManualPollingCachePolicy
constructor
A new instance of ManualPollingCachePolicy.
- #stop ⇒ Object
Constructor Details
#initialize(config_fetcher, config_cache) ⇒ ManualPollingCachePolicy
Returns a new instance of ManualPollingCachePolicy.
6 7 8 9 10 |
# File 'lib/configcat/manualpollingcachepolicy.rb', line 6 def initialize(config_fetcher, config_cache) @_config_fetcher = config_fetcher @_config_cache = config_cache @_lock = Concurrent::ReadWriteLock.new() end |
Instance Method Details
#force_refresh ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/configcat/manualpollingcachepolicy.rb', line 22 def force_refresh() begin configuration = @_config_fetcher.get_configuration_json() begin @_lock.acquire_write_lock() @_config_cache.set(configuration) ensure @_lock.release_write_lock() end rescue StandardError => e ConfigCat.logger.error "threw exception #{e.class}:'#{e}'" ConfigCat.logger.error "stacktrace: #{e.backtrace}" end end |
#get ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/configcat/manualpollingcachepolicy.rb', line 12 def get() begin @_lock.acquire_read_lock() config = @_config_cache.get() return config ensure @_lock.release_read_lock() end end |
#stop ⇒ Object
37 38 39 |
# File 'lib/configcat/manualpollingcachepolicy.rb', line 37 def stop() # pass end |