Class: Recot::Cache::StateCache
- Inherits:
-
Object
- Object
- Recot::Cache::StateCache
- Defined in:
- lib/recot/cache/state_cache.rb
Constant Summary collapse
- CACHE_FILE =
Cache directory name.
'.cahce'.freeze
- CACHE_KEY_NO =
Key of current test no.
'current_number'.freeze
- CACHE_KEY_RECENT_EVIDENCE =
Key of recent evidence file name.
'recent_evidence'.freeze
Class Method Summary collapse
-
.clear ⇒ Object
All clear cache.
-
.get_cache ⇒ Object
Get cache object.
-
.restore_no ⇒ Object
Get cached current test no.
-
.restore_recent_evidence ⇒ Object
Get cached recent evidence.
-
.store_no(number) ⇒ Object
Store current test no to cache.
-
.store_recent_evidence(evidence) ⇒ Object
Store recent evidence to cache.
Class Method Details
.clear ⇒ Object
All clear cache.
58 59 60 61 |
# File 'lib/recot/cache/state_cache.rb', line 58 def clear() fcache = get_cache() fcache.clear end |
.get_cache ⇒ Object
Get cache object.
Returns:
ActiveSupport::Cache object.
67 68 69 |
# File 'lib/recot/cache/state_cache.rb', line 67 def get_cache() ActiveSupport::Cache::FileStore.new(CACHE_FILE) end |
.restore_no ⇒ Object
Get cached current test no.
Returns:
Current test no.
33 34 35 36 |
# File 'lib/recot/cache/state_cache.rb', line 33 def restore_no() fcache = get_cache() fcache.read(CACHE_KEY_NO) end |
.restore_recent_evidence ⇒ Object
Get cached recent evidence.
Returns:
evidence file name.
51 52 53 54 |
# File 'lib/recot/cache/state_cache.rb', line 51 def restore_recent_evidence() fcache = get_cache() fcache.read(CACHE_KEY_RECENT_EVIDENCE) end |
.store_no(number) ⇒ Object
Store current test no to cache.
Parameters:
Test no for cache.
24 25 26 27 |
# File 'lib/recot/cache/state_cache.rb', line 24 def store_no(number) fcache = get_cache() fcache.write(CACHE_KEY_NO, number) end |
.store_recent_evidence(evidence) ⇒ Object
Store recent evidence to cache.
Parameters:
evidence file name.
42 43 44 45 |
# File 'lib/recot/cache/state_cache.rb', line 42 def store_recent_evidence(evidence) fcache = get_cache() fcache.write(CACHE_KEY_RECENT_EVIDENCE, evidence) end |