Cache

Extends Collection

Collection with extended custom caching features.

To create a new Cache Collection, initialise the class like below.

const CC = new QDB.Cache(Iterable?);

Take a look at the extended Collection class.

Properties

.Cached

Private

Cached array of values for optimisation purposes.
Type - Array<Val>

._Id

Private

The current ID tracker by the cache. Will not update once used.
Type - Number

Methods

.id()

Generates a new ID number for the Cache Collection.

Returns - Number

.set(Key, Val)

Extended

Main interaction point of the Cache Collection. Extended method to integrate further caching.

Parameter Type Description
Key Any The key of this entry.
Val Any The value of this pair.

Returns - Collection | This
Returns the Cache Collection itself.

.delete(Key)

Extended

Returns Collection if an element in the Collection object existed and has been removed, or false if the element does not exist. Col.has(Key) will return false afterwards. Extended due to further caching.

Parameter Type Description
Key Any The key of this entry.

Returns - Collection | This
Returns the Cache Collection itself.

.increment(Key)

Increments the value of the given Collection by one and caches it internally.

Parameter Type Description
Key Any The key of the value to be incremented.

Returns - Number
The new value of the element of the Collection.

.decrement(Key)

Decrements the value of the given Collection by one and caches it internally.

Parameter Type Description
Key Any The key of the value to be decremented.

Returns - Number
The new value of the element of the Collection.

.add(Key, Num)

Performs an addition operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the value to be added on.
Num Number The value to add to the item.

Returns - Number
The new value of the element of the Collection.

.subtract(Key, Num)

Performs a subtraction operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the value to be subtracted from.
Num Number The value to subtract from the item.

Returns - Number
The new value of the element of the Collection.

.multiply(Key, Num)

Performs a multiplication operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the value to be multiplied.
Num Number The second value of multiplication.

Returns - Number
The new value of the element of the Collection.

.divide(Key, Num)

Performs a division operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the value to be divided.
Num Number The second value of division.

Returns - Number
The new value of the element of the Collection.

.square(Key)

Performs a 'to the power of two' operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the value to be squared.

Returns - Number
The new value of the element of the Collection.

.power(Key, Num)

Performs an exponential operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the base value.
Num Number The relative exponent value.

Returns - Number
The new value of the element of the Collection.

.root(Key)

Performs a root operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the base value.

Returns - Number
The new value of the element of the Collection.

.exp(Key)

Performs an exponent on Euler's number on the given Cache Collection value.

Parameter Type Description
Key Any The key of the base value.

Returns - Number
The new value of the element of the Collection.

.absolute(Key)

Performs an abs operation on the given Cache Collection value.

Parameter Type Description
Key Any The key of the base value.

Returns - Number
The new value of the element of the Collection.

.accumulate(Key, fn)

Performs a function on an item.

Parameter Type Description
Key Any The key of the value to execute on.
fn Function Functions to execute on the item.

Returns - Number
The new value of the element.