Class: Arachni::Cache::LeastRecentlyUsed

Inherits:
Base show all
Defined in:
lib/arachni/cache/least_recently_used.rb

Overview

Least Recently Used cache implementation.

Generally the most desired mode under normal circumstances, although it does not satisfy low-latency requirements due to the overhead of maintaining entry ages.

Discards the least recently used entries in order to make room for new ones.

Author:

Instance Attribute Summary

Attributes inherited from Base

#max_size

Instance Method Summary collapse

Methods inherited from Base

#[]=, #any?, #capped?, #empty?, #fetch_or_store, #include?, #size, #uncap, #uncapped?

Constructor Details

#initializeLeastRecentlyUsed

Returns a new instance of LeastRecentlyUsed.

See Also:



30
31
32
33
# File 'lib/arachni/cache/least_recently_used.rb', line 30

def initialize( * )
    super
    @lru = []
end

Instance Method Details

#[](k) ⇒ Object

See Also:



43
44
45
46
47
# File 'lib/arachni/cache/least_recently_used.rb', line 43

def []( k )
    super( k )
ensure
    renew( k )
end

#clearObject

See Also:



57
58
59
60
61
# File 'lib/arachni/cache/least_recently_used.rb', line 57

def clear
    super
ensure
    @lru.clear
end

#delete(k) ⇒ Object

See Also:



50
51
52
53
54
# File 'lib/arachni/cache/least_recently_used.rb', line 50

def delete( k )
    super( k )
ensure
    @lru.delete( k )
end

#store(k, v) ⇒ Object

See Also:



36
37
38
39
40
# File 'lib/arachni/cache/least_recently_used.rb', line 36

def store( k, v )
    super( k, v )
ensure
    renew( k )
end