Class: SparkleFormation::Cache
- Inherits:
-
Object
- Object
- SparkleFormation::Cache
- Defined in:
- lib/sparkle_formation/utils.rb
Overview
Cache helper
Class Method Summary collapse
-
.[](k) ⇒ Object
Get value.
-
.[]=(k, v) ⇒ Object
Set value.
-
.init! ⇒ self
Initialize cache within thread.
Class Method Details
.[](k) ⇒ Object
Get value
74 75 76 77 |
# File 'lib/sparkle_formation/utils.rb', line 74 def [](k) init! Thread.current[:sparkle_cache][k] end |
.[]=(k, v) ⇒ Object
Set value
84 85 86 87 |
# File 'lib/sparkle_formation/utils.rb', line 84 def []=(k,v) init! Thread.current[:sparkle_cache][k] = v end |
.init! ⇒ self
Initialize cache within thread
92 93 94 95 96 97 |
# File 'lib/sparkle_formation/utils.rb', line 92 def init! unless(Thread.current[:sparkle_cache]) Thread.current[:sparkle_cache] = {} end self end |