1.0.0 • Published 6 years ago

cachedo v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

Table of Contents

CacheDo

Cache abstraction that supports merging cached values with new and key hashing

Parameters

  • cacheClass Class Caching class with get, put, del methods
  • options JSON Class operation definition
    • options.merge Boolean (false) Enable/Disable merging new value with present value if one exists
    • options.keys JSON Defines options specific to key management
      • options.keys.hashKey Boolean (false) Enable/Disable key hashing
      • options.keys.algorithm String (sha256) Defines algorith used during key hash
      • options.keys.digest String (hex) Defines digest used during key hash
      • options.keys.keyGen Function ((input)=>{return input}) Custom function to produce key
    • options.ttl Number (600) Define expire time of the cached value
    • options.timeoutCB (Undefined | Function) (Undefined) Custom callback function to be executed when cache value expires

Meta

  • version: 1.0.0

setCache

Validates caching function by ensuring that it contains methods get, put, del

Parameters

setOptions

Merges and returns a validated option set

Parameters

  • options JSON Class operation definition
    • options.merge Boolean (false) Enable/Disable merging new value with present value if one exists
    • options.keys JSON Defines options specific to key management
      • options.keys.hashKey Boolean (false) Enable/Disable key hashing
      • options.keys.algorithm String (sha256) Defines algorith used during key hash
      • options.keys.digest String (hex) Defines digest used during key hash
      • options.keys.keyGen Function ((input)=>{return input}) Custom function to produce key
    • options.ttl Number (600) Define expire time of the cached value
    • options.timeoutCB (Undefined | Function) (Undefined) Custom callback function to be executed when cache value expires

hashKey

Produces hash of parameter.

Parameters

setKet

Generates key based on configuration settings

Parameters

put

Pushes key/value pair to cache

Parameters

  • key String
  • value (Number | String | JSON) Value to be cached
  • options JSON Optional options passed that will override options used during class instantiation
    • options.merge String Enable/Disable merging new value with present value if one exists
    • options.ttl String Define expire time of the cached value
    • options.timeoutCB String Custom callback function to be executed when cache value expires

get

Calls cache to return value assigned to key

Parameters