Skip to content

[feature] - Add Rejson bindings #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ node_modules

*.env
dump.rdb
.idea/
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ var redisClient = require('redis-connection')();
// now use your redis connection
```

### Using `rejson` with `redis-connection-manager`

If you are using `rejson` module with your Redis build, you can enable rejson commands by setting the ENABLE_REJSON flag before requiring `redis-connection`.

```js
process.env.ENABLE_REJSON = true;
var redisClient = require('redis-connection')();
// now use your redis connection
````

## Need More?

If you need us to support a different Redis-as-a-service provider
Expand Down Expand Up @@ -155,4 +165,4 @@ If you are seeing a "_Redis Connection Error_" message in your terminal, e.g:

Either your local instance of Redis is not running or is running on a
different port from the standard which is **6379**.
Confirm Redis is running then try again!
Confirm Redis is running then try again!
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var redis = require('redis');
var url = require('url');
var rejson = require('redis-rejson');

var rc; // redis config
if (process.env.REDISCLOUD_URL) {
Expand All @@ -21,11 +22,16 @@ else {
var CON = {}; // store redis connections as Object

function new_connection () {
var redis_con = redis.createClient(rc.port, rc.host);
if (process.env.REDISCLOUD_URL && rc.auth) { // only auth on CI/Stage/Prod
redis_con.auth(rc.auth); // see: https://git.io/vH3TN
}
return redis_con;
//enable rejson if ENABLE_REJSON flag is set (the flag can have any value, we only check if it is set or not)
if(process.env.ENABLE_REJSON){
rejson(redis);
}

var redis_con = redis.createClient(rc.port, rc.host);
if (process.env.REDISCLOUD_URL && rc.auth) { // only auth on CI/Stage/Prod
redis_con.auth(rc.auth); // see: https://git.io/vH3TN
}
return redis_con;
}

function redis_connection (type) {
Expand Down
Loading