Class: TaskJuggler::DataCacheEntry
- Defined in:
- lib/taskjuggler/DataCache.rb
Overview
These are the entries in the DataCache. They store a value and an access counter. The counter can be read and written externally.
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#unhashedKey ⇒ Object
readonly
Returns the value of attribute unhashedKey.
Instance Method Summary collapse
-
#initialize(unhashedKey, value) ⇒ DataCacheEntry
constructor
Create a new DataCacheEntry for the value.
-
#value ⇒ Object
Return the value and increase the access counter by 1.
Constructor Details
#initialize(unhashedKey, value) ⇒ DataCacheEntry
Create a new DataCacheEntry for the value. We also store the unhashed key to be able to detect hash collisions. The access counter is set to 1 to increase the chance that it is not flushed immedidate.
29 30 31 32 33 |
# File 'lib/taskjuggler/DataCache.rb', line 29 def initialize(unhashedKey, value) @unhashedKey = unhashedKey @value = value @hits = 1 end |
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
24 25 26 |
# File 'lib/taskjuggler/DataCache.rb', line 24 def hits @hits end |
#unhashedKey ⇒ Object (readonly)
Returns the value of attribute unhashedKey.
23 24 25 |
# File 'lib/taskjuggler/DataCache.rb', line 23 def unhashedKey @unhashedKey end |
Instance Method Details
#value ⇒ Object
Return the value and increase the access counter by 1.
36 37 38 39 40 41 42 43 |
# File 'lib/taskjuggler/DataCache.rb', line 36 def value if @hits <= 0 @hits = 1 else @hits += 1 end @value end |