Class: Edgarj::Search::Cache

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeCache

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

#hitObject

Returns the value of attribute hit.



27
28
29
# File 'app/models/edgarj/search.rb', line 27

def hit
  @hit
end

#klass_hashObject

Returns the value of attribute klass_hash.



27
28
29
# File 'app/models/edgarj/search.rb', line 27

def klass_hash
  @klass_hash
end

#missObject

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_reportObject

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