Class Cache
Defined in: Utils.jsm.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Cache(size)
A cache with a fixed capacity, newer entries replace entries that have been
stored first.
|
| Field Attributes | Field Name and Description |
|---|---|
| <private> |
Index in the ring buffer to be written next.
|
| <private> |
Ring buffer storing hash keys, allows determining which keys need to be
evicted.
|
|
Cache data, maps values to the keys.
|
| Method Attributes | Method Name and Description |
|---|---|
|
add(key, value)
Adds a key and the corresponding value to the cache.
|
|
|
clear()
Clears cache contents.
|
Class Detail
Cache(size)
A cache with a fixed capacity, newer entries replace entries that have been
stored first.
- Parameters:
- {Integer} size
Field Detail
<private>
{Integer}
_bufferIndex
Index in the ring buffer to be written next.
<private>
{Array}
_ringBuffer
Ring buffer storing hash keys, allows determining which keys need to be
evicted.
{Object}
data
Cache data, maps values to the keys. Read-only access, for writing use
add() method.
Method Detail
add(key, value)
Adds a key and the corresponding value to the cache.
- Parameters:
- {String} key
- value
clear()
Clears cache contents.