Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
redis-serverclient
Advanced tools
A no-brainer Redis server + client singleton for node Apps
This npm package uses 'redis-server' and 'redis' npm packages and seves as a singleton wrapper over these awesome npm packages.
Install redis server first
a. Windows
b. Mac OS X brew install redis
c. Linux
Test Redis installation and port
a. Run redis-server
on a terminal
b. Run redis-cli
on another terminal and check if it connects
c. If everything goes well, close both the terminals.
Install redis-serverclient package npm i --save redis-serverclient
You can check the test.js
file on how to use it. This is pretty simple and straight-forward.
// file: app.js
const redis=require('redis-serverclient');
redis.init(function(err){
if(err)
console.log('Redis Error: ',err);
console.log('Redis running successfully!');
});
This will initiate redis server and client. You can pass an optional port redis.init(6379,function(err){...
.
If port is not passed, the default port used will be 6379
.
Since redis-serverclient is singleton, you need to initialize it only once in main/index.js file. Require it anywhere and it would maintain the same state.
const redis=require('redis-serverclient');
redis.client.set('name','Gangadhar');
redis.client exposes a redis object from the respective npm package. So, use it as you would use var redisClient=require('redis');
.
const redis=require('redis-serverclient');
redis.client.get('name',function(err,reply){
console.log('reply: ',reply);
});
redis.close();
This will close the active redis server AND client instance and any firther commands will be halted. Use this when your server is shutting down else, you may end up with error 'Address already in use'.
You may want to individually access the redis client and server, which you can easily get by redis.client and redis.server, respectively.
This package is free to use both commercially and personally without any limitations. However, the author shall not be liable for any damage occured during usage of this software.
'redis-server' and 'redis' packages are fully owned by their own authors(whose links are provided with the hyperlinks) and not me.
FAQs
A no-brainer Redis server + client singleton for node Apps
The npm package redis-serverclient receives a total of 0 weekly downloads. As such, redis-serverclient popularity was classified as not popular.
We found that redis-serverclient demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.