new Cache(options, redisOptions){Cache}
| Name | Type | Description |
|---|---|---|
options |
object |
Cache options |
redisOptions |
redisOptions |
Redis client options. |
Returns:
| Type | Description |
|---|---|
| Cache |
|
Methods
-
_getClient()
cache.js, line 48 -
Internal - Using this may induce unintended behaviors.
Returns:
An npm::redis client. -
_setClient(client)
cache.js, line 40 -
Internal - Using this may induce unintended behaviors.
Name Type Description clientRedisClient An npm::redis client that has already been connected.
-
bucketify(documents){Object}
cache.js, line 319 -
Determine which buckets need to be cached.
Name Type Description documentsArray Array of MongoDB documents to cache.
Returns:
Type Description Object -
asyncclose(){void}
cache.js, line 91 -
Attempts to close the Redis client collection.
Returns:
Type Description void -
asyncconnect(){Promise}
cache.js, line 56 -
Attempts to establish a connection to Redis
Returns:
Type Description Promise Resolves -
debucketify(queryList){Object}
cache.js, line 346 -
Determine which buckets need to be retrieved.
Name Type Description queryListArray The list of document IDs.
Returns:
Type Description Object The cache operations to carry out. -
asyncgetDocument(documentID){String}
cache.js, line 185 -
Retrieve a single document from a bucket.
Name Type Description documentIDString The document ID as a string.
Returns:
Type Description String The document data. -
asyncgetDocuments(queryList, options){Array|Stream}
cache.js, line 124 -
Retrieves cached documents from a queryList.
Name Type Default Description queryListArray The list of document IDs.
optionsObject {} optional Name Type Default Description hydrateboolean false optional JSON.parse documents and attempt to reformat types (performance hit).
streamboolean false optional Return as a stream.
ndjsonboolean false optional When streaming, use the ndJSON spec.
Returns:
Type Description Array | Stream -
asyncgetQueryHash(queryHash, query){String}
cache.js, line 263 -
Gets the document ID associated with a particular query
Name Type Description queryHashString The hash name version of a query.
queryString The query to retreive.
Returns:
Type Description String The document ID. -
asyncgetQueryList(queryKey){QueryMatch}
cache.js, line 227 -
Gets the queryList associated with the provided QueryKey
Name Type Description queryKeyQueryKey The QueryKey
Returns:
Type Description QueryMatch -
asyncgetWideMatch(queryKey){Array|null}
cache.js, line 287 -
Attempts to find a previously cached query that contains our requested data.
Name Type Description queryKeyQueryKey The QueryKey.
Returns:
Type Description Array | null -
asyncsetDocument(document, requestedID){void}
cache.js, line 199 -
Caches a single document into an appropriate bucket.
Name Type Description documentObject The document to cache.
requestedIDString | ObjectID The document ID as a ObjectID instance or String.
Returns:
Type Description void -
asyncsetDocuments(queryKey, documents){void}
cache.js, line 153 -
Sets the queryList and caches documents into Redis.
Name Type Description queryKeyQueryKey The QueryKey to use when caching.
documentsArray The documents to cache (from MongoDB).
Returns:
Type Description void -
asyncsetQueryHash(queryHash, args){void}
cache.js, line 275 -
Sets a key-value pair in the queryHash
Name Type Description queryHashString The hash name version of a query.
argsany repeatable The query-documentID pair to set.
Returns:
Type Description void -
asyncsetQueryList(queryKey, queryList){void}
cache.js, line 251 -
Sets the queryList
Name Type Description queryKeyQueryKey The QueryKey.
queryListArray The list of document IDs.
Returns:
Type Description void