1.11.1 • Published 6 years ago

newredis v1.11.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

A Modern Redis Client

Introduction

This is a pure Javascript based redis client(including a connection pool implementation). All code are written in the newest JS standard (async/await & Promise). All related exceptions and events are handled so you can write you code as easy as possible.

Usage

There are two class exported by this package: RedisConnection and RedisPool. I will suggest using RedisPool only, because it contains broken connection repairing, which is important in production environment. Besides, the API is pretty simple.

First, install it through npm:

npm install newredis

Then import the library and create a client like this:

const { RedisPool } = require("newredis")
const pool = new RedisPool({ port: 6379, host: "localhost", password: "asdf" })

If you are using the default host(localhost) and default port(6379), you can simply write:

const pool = new RedisPool({ password: "asdf" })

If the requirepass in redis configuration is not enabled, you can even write:

const pool = new RedisPool()

Now you can use it in Promise way:

pool.getConnection()
.then(conn => {
  return conn.execute([ "get", "hello" ]).then(r => [ conn, r ])
})
.then(([ conn, r ]) => {
  conn.release()
  console.log("R:", r)
})
.catch(e => {
  console.error("E:", e)
})

Or in async/await way:

async function testConn() {
  const conn = await pool.getConnection()

  const r = await conn.execute([ "get", "hello" ])
  console.log("R:", r)

  conn.release()
}

testConn()
.catch(e => console.error("E:", e))

If you really want to use RedisConnection instead of RedisPool, there are some examples in test directory.

1.11.1

6 years ago

1.11.0

6 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.9.3

6 years ago

0.9.2

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.3

6 years ago

0.8.2

6 years ago

0.8.1

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.4

6 years ago

0.6.3

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.3

6 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.0

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago