0.0.4 â€ĸ Published 1 year ago

@graphshieldhq/cache v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Versioning Twitter Follow

Cache Module

An opinionated cache management module that works bith in-memory and with Redis.

💡 Features

🚀 Get Started

Installation

npm install --save @graphshieldhq/cache

Initialization

import cache from '@graphshieldhq/cache'
cache.init({
    cache_driver = 'in-memory',
    redis_host = 'localhost',
    redis_port = 6379,
    redis_database_index = 0,
    redis_tls = false,
    redis_password = '',
    redis_reconnect_attempts = 0,
    redis_reconnect_delay = 1000,
    cache_keys_prefix = 'cache:',
    logging = console.log
})

The initialization options must be an object with properties as specified in the options schema.

Usage

// Set data
const setResult = await cache.set({
    key: 'test',
    value: 'test',
    ttl: 1000 // In milliseconds
})
console.log(setResult) // Is `true` if successful
// Get data
const value = await cache.get({ key: 'test' })
console.log(value)

Additional resources

0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago