1.0.1 • Published 6 years ago
ads-cache v1.0.1
ADS CACHE
Redis is missing in special private cloud environments, with ads as an alternative. This package provides common commands in redis such as set, get, del, etc., less codes would be modified to complete the migration from redis to ads.
Install Package
$ npm install ads-cache --save
Usage
const AdsCache = require('ads-cache')
INIT CLIENT
- the redis config VS ads config
property | redis | ads |
---|---|---|
host | host | host |
port | port | port |
password | auth | password |
database | x | database |
tableGroup | x | tableGroup |
table | db | table |
const host = 'ads-host' // required
const port = ads-port // required
const user = 'user' // required
const password = 'password' // required
const database = 'databse' // required
const tableGroup = 'table group' // table group is required for each table in ads
const table = 'zero' // optional the table name default is zero
const prefix = 'gj:' // optional you could set each key prefix for namespace
const client = new AdsCache({
host,
port,
user,
password,
database,
tableGroup,
prefix,
table
})
SET
await client.set('key', 'value') // 'OK'
GET
await client.get('key') // 'value'
DEL
await client.del('key') // 'OK'
await client.del('key1', 'key2', 'key3')
EXPIRE
await client.expire('key', 30) // 30s
SELECT
await client.select('one') // change to table one, create table one if not exists automatically