Class: Edgar::Search::Cache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
app/models/edgar/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

- (Cache) initialize

A new instance of Cache



29
30
31
32
33
34
35
# File 'app/models/edgar/search.rb', line 29

def initialize
  @klass_hash = {}
  
  # for cache statistics
  @hit   = 0
  @miss  = 0
end

Instance Attribute Details

- (Object) hit

Returns the value of attribute hit



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

def hit
  @hit
end

- (Object) klass_hash

Returns the value of attribute klass_hash



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

def klass_hash
  @klass_hash
end

- (Object) miss

Returns the value of attribute miss



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

def miss
  @miss
end

Instance Method Details

- (Object) klass_hash_report

report hit rate



38
39
40
# File 'app/models/edgar/search.rb', line 38

def klass_hash_report
  sprintf("%d/%d", @hit, @hit + @miss)
end