NodeJS Client for RedisJSON
npm install redis-json-client
shell
npm install redis-json-client
`
Basic Usage
`javascript
const RedisJSONClient = require('redis-json-client')
const opts = {
ports: 6379,
hosts: '127.0.0.1',
db: 0,
password: 'password'
}
or
const opts = "/tmp/redis.sock"
const client = new RedisJSONClient(opts)
// Redis 연결
client.connect()
.then(_ => {
// 데이터 저장 (부모가 존재하지 않으면 생성)
client.set('key', 'path.a.b', {alpha: 'beta'}, {recursive: true})
.then(_ => {
// 데이터 불러오기
client.get('key', 'path.a.b.alpha')
.then(json => {
console.log(json)
})
})
})
.catch(err => {
console.error(err)
process.exit()
})
`
Command Examples
$3
`javascript
client.get(key, path)
.then(json)
.catch(err)
`
$3
`javascript
client.set(key, path, value, { recursive: true })
.then(result)
.catch(err)
`
$3
`javascript
client.del(key, path)
.then(result)
.catch(err)
`
$3
`javascript
client.forgot(key, path)
.then(result)
.catch(err)
`
$3
`javascript
client.type(key, path)
.then(type)
.catch(err)
`
$3
`javascript
client.mget(keys, path)
.then(json)
.catch(err)
`
$3
`javascript
client.inc(key, path, value)
.then(json)
.catch(err)
`
$3
`javascript
client.mul(key, path, value)
.then(json)
.catch(err)
`
$3
`javascript
client.strand(key, path, value)
.then(length)
.catch(err)
`
$3
`javascript
client.strlen(key, path)
.then(length)
.catch(err)
`
$3
`javascript
client.arrand(key, path, values)
.then(size)
.catch(err)
`
$3
`javascript
client.arridx(key, path, value)
.then(index)
.catch(err)
`
$3
`javascript
client.arrins(key, path, index, values)
.then(size)
.catch(err)
`
$3
`javascript
client.arrlen(key, path)
.then(size)
.catch(err)
`
$3
`javascript
client.arrpop(key, path, [index])
.then(json)
.catch(err)
`
$3
`javascript
client.arrtrim(key, path, start, end)
.then(size)
.catch(err)
`
$3
`javascript
client.objkeys(key, path)
.then(json)
.catch(err)
`
$3
`javascript
client.objlen(key, path)
.then(size)
.catch(err)
`
$3
`javascript
client.debug(args)
.then(json)
.catch(err)
`
$3
`javascript
client.resp(args)
.then(json)
.catch(err)
``