new Collection(configurationsopt) → {Collection}
Create a new collection
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
configurations |
Object |
<optional> |
configurations for collection
Properties
|
- Source:
Returns:
- Type
- Collection
Methods
addCache(id, cache, populate) → {this}
Add a cache
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | id of cache |
cache |
cache.Server | server's cache client |
populate |
PopulateFunction | function called to populate cache |
- Source:
Returns:
for chaining
- Type
- this
addSource(source) → {this}
Add a source of data.
While it might seem too much, I shall add option to add more than one
source of data. This might be useful if more sources would ensure more
fault tolerance or we actually have different sources.
If a cache can not be resolved, the message is ignored.
If an error occurs while adding an item to cache, it is ignored.
Parameters:
Name | Type | Description |
---|---|---|
source |
EventEmitter | an Event Emitter |
- Source:
Returns:
for chaining
- Type
- this
getCache(id) → {cache.Server|undefined}
Return a reference to a cache. Returns 'undefined' if cache is not found.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number | id of the cache |
- Source:
Returns:
- Type
- cache.Server | undefined
startRefreshInterval(optionsopt) → {this}
Start the refresh interval
Parameters:
Name | Type | Attributes | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- this
stopRefreshInterval() → {this}
Stop the refresh interval
- Source:
Returns:
- Type
- this
switch(choose) → {this}
Add function for deciding which cache is to be used
If the function returns `null`, or the id it returns does
not resolve to a cache, the message is ignored.
Parameters:
Name | Type | Description |
---|---|---|
choose |
SwitchFunction | choose function |
- Source:
Returns:
for chaining
- Type
- this