Show:

Q.Cache Class

Module: Q

Q.Cache constructor

Constructor

Q.Cache

(
  • [options={}]
)

Parameters:

  • [options={}] Object optional

    you can pass the following options:

    • [max=100] Integer optional

      the maximum number of items the cache should hold. Defaults to 100.

    • [after] Q.Cache optional

      pass an existing cache with max > this cache's max, to look in first

Item Index

Methods

Methods

clear

(
  • key
)

Clears Cache data and sets it to {}

Parameters:

each

(
  • args
  • callback
)

Cycles through all the entries in the cache

Parameters:

  • args Array

    An array consisting of some or all the arguments that form the key

  • callback Function

    Is passed two parameters: key, value, with this = the cache

get

(
  • key
  • options
)
Mixed

Accesses the cache and gets an entry from it

Parameters:

  • key String
  • options Object

    supports the following options:

    • [dontTouch=false] Boolean optional

      if true, then doesn't mark item as most recently used

Returns:

Mixed:

whatever is stored there, or else returns undefined

key

(
  • args
  • functions
)
String static

Generates the key under which things will be stored in a cache

Parameters:

  • args Array

    the arguments from which to generate the key

  • functions Array

    optional array to which all the functions found in the arguments will be pushed

Returns:

process

(
  • name
  • options
)
Mixed static

Parameters:

Returns:

Mixed:

remove

(
  • key
)
Boolean

Accesses the cache and removes an entry from it.

Parameters:

  • key String

    the key of the entry to remove

Returns:

Boolean:

whether there was an existing entry under that key

set

(
  • key
  • cbpos
  • subject
  • params
  • options
)
Boolean

Accesses the cache and sets an entry in it

Parameters:

  • key String

    the key to save the entry under, or an array of arguments

  • cbpos Number

    the position of the callback

  • subject Object

    The "this" object for the callback

  • params Array

    The parameters for the callback

  • options Object

    supports the following options:

    • [dontTouch=false] Boolean optional

      if true, then doesn't mark item as most recently used

Returns:

Boolean:

whether there was an existing entry under that key