Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

QueuedCache Class Reference

Inheritance diagram for QueuedCache:

PlainCache VirtualCache List of all members.

Public Member Functions

 this (uint capacity, uint concurrency=16)
IPayload get (char[] key)
IPayload put (char[] key, IPayload item)
IPayload extract (char[] key, ulong timeLimit=ulong.max)
QueuedEntry createQueuedEntry (char[] key, IPayload entry)

Private Member Functions

final QueuedEntry deReference (QueuedEntry entry)
final QueuedEntry reReference (QueuedEntry entry)
final QueuedEntry addEntry (char[] key, IPayload item)
IPayload extract (char[] key)
ICache bind (ICacheLoader loader)

Private Attributes

QueuedEntry head
QueuedEntry tail
int entries
int capacity

Detailed Description

QueuedCache extends the basic cache type by adding a limit to the number of items contained at any given time. In addition, QueuedCache sorts the cache entries such that those entries frequently accessed are at the head of the queue, and those least frequently accessed are at the tail. When the queue becomes full, old entries are dropped from the tail and are reused to house new cache entries.

This is great for keeping commonly accessed items around, while limiting the amount of memory used. Typically, the queue size would be set in the hundreds (perhaps thousands).

Definition at line 59 of file QueuedCache.d.


Member Function Documentation

this uint  capacity,
uint  concurrency = 16
[inline]
 

Construct a cache with the specified maximum number of entries. Additions to the cache beyond this number will reuse the slot of the least-recently-referenced cache entry. The concurrency level indicates approximately how many threads will content for write access at one time.

Reimplemented from PlainCache.

Definition at line 79 of file QueuedCache.d.

References capacity.

IPayload get char[]  key  )  [inline]
 

Get the cache entry identified by the given key

Reimplemented from PlainCache.

Reimplemented in VirtualCache.

Definition at line 91 of file QueuedCache.d.

Referenced by ChannelCache::get(), ChannelCache::lockWhereInvalid(), ServletProvider::service(), and testQueuedCache().

IPayload put char[]  key,
IPayload  item
[inline]
 

Place an entry into the cache and associate it with the provided key. Note that there can be only one entry for any particular key. If two entries are added with the same key, the second effectively overwrites the first.

Returns what it was given

Reimplemented from PlainCache.

Reimplemented in VirtualCache.

Definition at line 114 of file QueuedCache.d.

Referenced by testQueuedCache().

IPayload extract char[]  key,
ulong  timeLimit = ulong.max
[inline]
 

Remove (and return) the cache entry associated with the provided key. Returns null if there is no such entry.

Reimplemented from PlainCache.

Reimplemented in VirtualCache.

Definition at line 142 of file QueuedCache.d.

Referenced by ChannelCache::extract().

QueuedEntry createQueuedEntry char[]  key,
IPayload  entry
[inline]
 

Overridable factory for creating list entries.

Definition at line 167 of file QueuedCache.d.

final QueuedEntry deReference QueuedEntry  entry  )  [inline, private]
 

Place a cache entry at the tail of the queue. This makes it the least-recently referenced.

Definition at line 181 of file QueuedCache.d.

final QueuedEntry reReference QueuedEntry  entry  )  [inline, private]
 

Move a cache entry to the head of the queue. This makes it the most-recently referenced.

Definition at line 203 of file QueuedCache.d.

final QueuedEntry addEntry char[]  key,
IPayload  item
[inline, private]
 

Add an entry into the queue. If the queue is full, the least-recently-referenced entry is reused for the new addition.

Definition at line 226 of file QueuedCache.d.

IPayload extract char[]  key  )  [inline, inherited]
 

Remove (and return) the cache entry associated with the provided key. Returns null if there is no such entry.

Definition at line 105 of file PlainCache.d.

References HashMap::remove().

Referenced by testPlainCache().

ICache bind ICacheLoader  loader  )  [inline, inherited]
 

This is a factory for producing an ICache instance upon the cache content. The provided loader will populate the cache whenever a stale or missing entry is seen

Reimplemented from IMutableCache.

Definition at line 137 of file PlainCache.d.

References PlainCache::get(), IPayload::getTime(), ICacheLoader::load(), and ICacheLoader::test().


Member Data Documentation

QueuedEntry head [private]
 

Definition at line 62 of file QueuedCache.d.

QueuedEntry tail [private]
 

Definition at line 62 of file QueuedCache.d.

int entries [private]
 

Definition at line 66 of file QueuedCache.d.

int capacity [private]
 

Definition at line 66 of file QueuedCache.d.

Referenced by this().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:09 2004 for Mango by doxygen 1.3.6