Class: Bio::GFFbrowser::Digest::LruTracker
- Inherits:
-
Object
- Object
- Bio::GFFbrowser::Digest::LruTracker
- Includes:
- Helpers::Logger
- Defined in:
- lib/bio/db/gff/digest/gfflrucache.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#misses ⇒ Object
Returns the value of attribute misses.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, item) ⇒ Object
- #display(msg) ⇒ Object
-
#initialize ⇒ LruTracker
constructor
A new instance of LruTracker.
Methods included from Helpers::Logger
#debug, #error, #info, #log_sys_info, #warn
Constructor Details
#initialize ⇒ LruTracker
Returns a new instance of LruTracker.
109 110 111 112 113 114 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 109 def initialize @cache = LRUHash.new 50000 @hits = 0 @misses = 0 @calls = 0 end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
107 108 109 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 107 def cache @cache end |
#calls ⇒ Object
Returns the value of attribute calls.
106 107 108 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 106 def calls @calls end |
#hits ⇒ Object
Returns the value of attribute hits.
106 107 108 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 106 def hits @hits end |
#misses ⇒ Object
Returns the value of attribute misses.
106 107 108 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 106 def misses @misses end |
Instance Method Details
#[](name) ⇒ Object
116 117 118 119 120 121 122 123 124 125 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 116 def [](name) @calls += 1 item = @cache[name] if @cache[name] == nil @misses += 1 else @hits += 1 end item end |
#[]=(name, item) ⇒ Object
127 128 129 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 127 def []=(name,item) @cache[name] = item end |
#display(msg) ⇒ Object
130 131 132 133 134 |
# File 'lib/bio/db/gff/digest/gfflrucache.rb', line 130 def display msg info "Cache calls #{msg} = #{@calls}" info "Cache hits #{msg} = #{@hits}" info "Cache misses #{msg} = #{@misses}" end |