Class: TStore

TStore

TStore is a simple javascript object whose purpose is to store some ket/value data to future usage. It could be enable/disable.

new TStore( [parameters])

Parameters:
Name Type Argument Default Description
parameters Object <optional>
{}
Properties
Name Type Argument Default Description
collection Object <optional>
{}
allowOverride Boolean <optional>
false
keyValidators Array.<function()> <optional>
[]
valueValidators Array.<function()> <optional>
[]
Author:
License:
Source:
Example
var cache = new TCache()
cache.add( 'foo', 'bar' )
TLogger.log( cache.get('foo') ) // 'bar'

Members


allowOverride

Source:

collection

Source:

keys

Source:

keyValidators

Source:

values

Source:

valueValidators

Source:

Methods


<private, static> _validate(value, validators)

Parameters:
Name Type Description
value
validators
Source:

add(key, value, force)

Allow to add new key value pair, the key cannot be null, undefined, or an empty string. In case the key already exist, the value will be overwritten if force params is true or this allow overriding else it throw an TypeError.
Parameters:
Name Type Default Description
key *
value *
force Boolean false
Source:
Returns:
The current instance (this)
Type
TStore

clear()

Clear the cache and reset collection to an empty object.
Source:
Returns:
The current instance (this)
Type
TStore

contain(key)

Parameters:
Name Type Description
key
Source:
Returns:
Type
boolean

get(key)

Return the value associated to the key.
Parameters:
Name Type Description
key
Source:
Returns:
Type
*

remove(key)

Remove to value from the cache. Does nothing if the key does not exist.
Parameters:
Name Type Description
key
Source:
Returns:
The current instance (this)
Type
TStore

setAllowOverride(value)

Parameters:
Name Type Description
value
Source:
Returns:
The current instance (this)
Type
TStore

setCollection(value)

Parameters:
Name Type Description
value
Source:
Returns:
The current instance (this)
Type
TStore

setKeyValidators(value)

Parameters:
Name Type Description
value
Source:
Returns:
The current instance (this)
Type
TStore

setValueValidators(value)

Parameters:
Name Type Description
value
Source:
Returns:
The current instance (this)
Type
TStore