3.3.0 • Published 4 months ago

kth-node-redis v3.3.0

Weekly downloads
402
License
MIT
Repository
github
Last release
4 months ago

kth-node-redis

Redis client module for Node.js. (Everything with Promises)

Usage

const redis = require('kth-node-redis')

// basics
redis('default', {
  /* optional redis client config */
})
  .then(function (client) {
    return client.getAsync('key')
  })
  .then(function (value) {
    // do something with value
  })
  .catch(function (err) {
    // handle error
  })

// multi
redis('default', {
  /* optional redis client config */
})
  .then(function (client) {
    return client.multi().hmset('foo', { value: 'bar' }).expire('foo', 30).hgetall('foo').execAsync()
  })
  .then(function (results) {
    // results[1] => 'OK'
    // results[1] => 1
    // results[2] => { value: 'bar' }
    // results will depend on what commands are executed
  })
  .catch(function (err) {
    // handle error
  })

// quit if needed
redis.quit('default')

Options

  • name optional name, defaults to default. Use the same name to get the same client instance or re-create it. Use a new name to create a new instance.
  • options optional config for the Redis client. Has a default retry strategy. See below for details. For info about the Redis client options, see https://www.npmjs.com/package/redis.

Default retry strategy

function retry_strategy(options) {
  if (options.error.code === 'ECONNREFUSED') {
    return new Error('Connection refused by server.')
  }

  if (options.total_retry_time > 1000 * 60 * 60) {
    return new Error('Retry time exhausted')
  }

  if (options.times_connected > 10) {
    return undefined
  }

  return Math.max(options.attempt * 100, 3000)
}
3.3.0

4 months ago

3.2.0

8 months ago

3.1.47-0

10 months ago

3.1.47

10 months ago

3.1.45

1 year ago

3.1.46

1 year ago

3.1.44

2 years ago

3.1.41

2 years ago

3.1.43

2 years ago

3.1.42

2 years ago

3.1.38

2 years ago

3.1.39

2 years ago

3.1.40

2 years ago

3.1.36

2 years ago

3.1.37

2 years ago

3.1.34

3 years ago

3.1.33

3 years ago

3.1.35

3 years ago

3.1.32

3 years ago

3.1.31

3 years ago

3.1.29

3 years ago

3.1.30

3 years ago

3.1.27

3 years ago

3.1.28

3 years ago

3.1.26

3 years ago

3.1.25

3 years ago

3.1.24

3 years ago

3.1.23

3 years ago

3.1.22

3 years ago

3.1.21

3 years ago

3.1.20

3 years ago

3.1.19

3 years ago

3.1.18

3 years ago

3.1.17

3 years ago

3.1.16

3 years ago

3.1.15

3 years ago

3.1.14

3 years ago

3.1.12

3 years ago

3.1.13

3 years ago

3.1.11

3 years ago

3.1.10

3 years ago

3.1.9

3 years ago

3.1.8

3 years ago

3.1.7

4 years ago

3.1.6

4 years ago

3.1.5

4 years ago

3.1.3

4 years ago

3.1.4

4 years ago

3.1.2

4 years ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.6

4 years ago

3.0.4

4 years ago

3.0.5

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.0

7 years ago