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
114 115 116 117 |
# File 'lib/sparkle_formation/utils.rb', line 114 def [](k) init! Thread.current[:sparkle_cache][k] end |
.[]=(k, v) ⇒ Object
Set value
124 125 126 127 |
# File 'lib/sparkle_formation/utils.rb', line 124 def []=(k, v) init! Thread.current[:sparkle_cache][k] = v end |
.init! ⇒ self
Initialize cache within thread
132 133 134 135 136 137 |
# File 'lib/sparkle_formation/utils.rb', line 132 def init! unless(Thread.current[:sparkle_cache]) Thread.current[:sparkle_cache] = {} end self end |