Class: RubyScope::SexpCache
- Inherits:
-
Object
- Object
- RubyScope::SexpCache
- Defined in:
- lib/ruby_scope/sexp_cache.rb
Defined Under Namespace
Classes: CacheEntry
Constant Summary collapse
- DB =
DBM
Instance Method Summary collapse
- #[](path) ⇒ Object
- #[]=(path, value) ⇒ Object
- #cache_path ⇒ Object
-
#initialize(root) ⇒ SexpCache
constructor
A new instance of SexpCache.
Constructor Details
Instance Method Details
#[](path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_scope/sexp_cache.rb', line 10 def [] path with_cache do |cache| entry = cache[path] entry = Marshal.load(entry) if entry if entry && entry.last_modified == last_modified(path) entry.sexp else cache.delete path nil end end end |
#[]=(path, value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ruby_scope/sexp_cache.rb', line 24 def []= path,value with_cache do |cache| entry = CacheEntry.new(last_modified(path), value) cache[path] = Marshal.dump(entry) end end |
#cache_path ⇒ Object
31 32 33 |
# File 'lib/ruby_scope/sexp_cache.rb', line 31 def cache_path @cache_path ||= File.join(@root,'.ruby_scope.cache') end |