# ECCache

## Abstract

Class used for a simple caching.

## Discussion

At present the underlying mechanism is very simple: If the object has a reference counter value of greater/equal 1 then the object relies in the dictionary. If the counter equals 0 then the object will be removed.

Please note that the "reference counter" mentioned here refers to cache-internal counter and not to that of an object in general.

## Methods

`-addObject`
  adds an object to the cache.
`-addObject:forKey:`
  adds an object to the cache.
`-allKeys`
`-decrementRefCounterFor`
  Decrements the internal reference counter by one of the object identified by the given key.
`-decrementRefCounterForKey:`
  Decrements the internal reference counter by one of the object identified by the given key.
`-objectExistsForKey:`
  checks wether an object exists for the given key
`-objectForKey`
  get the cached object identified by the given key
`-objectForKey:incrementRefCounter:`
  get the cached object identified by the given key
`-referenceCounterOfObjectForKey:`
`-referenceCountOfObjectForKey`
`-removeObjectForKey:`
  removes the specified entry from the cache

### addObject

adds an object to the cache.

See Also:

> addObject:forKey:

>     - addObject: (id) anObject forKey: (id <NSCopying>) aKey;

method result
  self

### addObject:forKey:

adds an object to the cache.

See Also:

> addObject

>     - addObject: (id) anObject forKey: (id <NSCopying>) aKey;

### allKeys

>     - (id <ECIterator>) allKeys;

method result
  iterator over all keys

### decrementRefCounterFor

Decrements the internal reference counter by one of the object identified by the given key.

See Also:

> decrementRefCounterForKey:

>     - (void) decrementRefCounterForKey: (id) aKey;

### decrementRefCounterForKey:

Decrements the internal reference counter by one of the object identified by the given key.

See Also:

> decrementRefCounterFor

>     - (void) decrementRefCounterForKey: (id) aKey;

### objectExistsForKey:

checks wether an object exists for the given key

>     - (BOOL) objectExistsForKey: (id) aKey;

##### Parameter Descriptions

> `aKey`
>   key of the object

method result
  YES if existent, NO otherwise

### objectForKey

get the cached object identified by the given key

See Also:

> objectForKey:incrementRefCounter:

>     - objectForKey: (id) aKey incrementRefCounter: (BOOL) doIncrement;

##### Parameter Descriptions

> `doIncrement`
>   The internal reference count will be incremented by 1 if this parameter equals YES

method result
  related object or nil if not existent

### objectForKey:incrementRefCounter:

get the cached object identified by the given key

See Also:

> objectForKey

>     - objectForKey: (id) aKey incrementRefCounter: (BOOL) doIncrement;

##### Parameter Descriptions

> `doIncrement`
>   The internal reference count will be incremented by 1 if this parameter equals YES

### referenceCounterOfObjectForKey:

See Also:

> referenceCountOfObjectForKey

>     - (unsigned int) referenceCounterOfObjectForKey: (id) aKey;

##### Parameter Descriptions

> `aKey`
>   key of object to look for.

### referenceCountOfObjectForKey

See Also:

> referenceCounterOfObjectForKey:

>     - (unsigned int) referenceCounterOfObjectForKey: (id) aKey;

##### Parameter Descriptions

> `aKey`
>   key of object to look for.

method result
  return the current reference count for the specified object. Return 0 if the object does not exist

### removeObjectForKey:

removes the specified entry from the cache

>     - (void) removeObjectForKey: (id) aKey;

##### Parameter Descriptions

> `aKey`
>   key of the entry to be removed

##### Discussion

Does nothing if the element could not be found.

(Last Updated August 27, 2006)