Class: Edgarj::Search::Cache
- Inherits:
-
Object
- Object
- Edgarj::Search::Cache
- Includes:
- Singleton
- Defined in:
- app/models/edgarj/search.rb
Overview
cache the map: column name -> column type
SearchForm instance is serialized to be stored at session so that another class (=Cache) is introduced to store cache information.
Instance Attribute Summary collapse
-
#hit ⇒ Object
Returns the value of attribute hit.
-
#klass_hash ⇒ Object
Returns the value of attribute klass_hash.
-
#miss ⇒ Object
Returns the value of attribute miss.
Instance Method Summary collapse
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
-
#klass_hash_report ⇒ Object
report hit rate.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
29 30 31 32 33 34 35 |
# File 'app/models/edgarj/search.rb', line 29 def initialize @klass_hash = {} # for cache statistics @hit = 0 @miss = 0 end |
Instance Attribute Details
#hit ⇒ Object
Returns the value of attribute hit.
27 28 29 |
# File 'app/models/edgarj/search.rb', line 27 def hit @hit end |
#klass_hash ⇒ Object
Returns the value of attribute klass_hash.
27 28 29 |
# File 'app/models/edgarj/search.rb', line 27 def klass_hash @klass_hash end |
#miss ⇒ Object
Returns the value of attribute miss.
27 28 29 |
# File 'app/models/edgarj/search.rb', line 27 def miss @miss end |
Instance Method Details
#klass_hash_report ⇒ Object
report hit rate
38 39 40 |
# File 'app/models/edgarj/search.rb', line 38 def klass_hash_report sprintf("%d/%d", @hit, @hit + @miss) end |