1.0.1 • Published 6 years ago

ads-cache v1.0.1

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

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
propertyredisads
hosthosthost
portportport
passwordauthpassword
databasexdatabase
tableGroupxtableGroup
tabledbtable
  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
1.0.1

6 years ago

1.0.0

6 years ago