3.4.0 • Published 3 months ago

kth-node-redis v3.4.0

Weekly downloads
402
License
MIT
Repository
github
Last release
3 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.4.0

3 months ago

3.4.0-0

3 months ago

3.3.0

1 year ago

3.2.0

2 years ago

3.1.47-0

2 years ago

3.1.47

2 years ago

3.1.45

2 years ago

3.1.46

2 years ago

3.1.44

3 years ago

3.1.41

3 years ago

3.1.43

3 years ago

3.1.42

3 years ago

3.1.38

3 years ago

3.1.39

3 years ago

3.1.40

3 years ago

3.1.36

4 years ago

3.1.37

3 years ago

3.1.34

4 years ago

3.1.33

4 years ago

3.1.35

4 years ago

3.1.32

4 years ago

3.1.31

4 years ago

3.1.29

4 years ago

3.1.30

4 years ago

3.1.27

4 years ago

3.1.28

4 years ago

3.1.26

4 years ago

3.1.25

4 years ago

3.1.24

4 years ago

3.1.23

4 years ago

3.1.22

4 years ago

3.1.21

4 years ago

3.1.20

4 years ago

3.1.19

4 years ago

3.1.18

4 years ago

3.1.17

4 years ago

3.1.16

4 years ago

3.1.15

4 years ago

3.1.14

4 years ago

3.1.12

4 years ago

3.1.13

4 years ago

3.1.11

4 years ago

3.1.10

4 years ago

3.1.9

4 years ago

3.1.8

4 years ago

3.1.7

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.3

5 years ago

3.1.4

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.6

5 years ago

3.0.4

5 years ago

3.0.5

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.1

6 years ago

2.0.0

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.0

8 years ago