next-cache
v1.3.3
Published
This is a server side rendering cache service It is suitable for clustering and distributed application
Downloads
209
Readme
next-cache
This is a server side rendering cache service
It is suitable for clustering and distributed application
environment
node 10.15.3
npm 6.4.1
install
npm install next-cache
start
// server
const NextCache = require("next-cache");
const server = new NextCache.Server({
port: 666,
});
server.start();
// client
const NextCache = require("next-cache");
const cache = new NextCache.Client("ws://localhost:666");
await cache.connect();
const data = await cache.get(`your_cache_key`, async()=>{
return await new Promise(resolve => {
setTimeout(()=>{
resolve({
value: 123, // your data
ttl: 3600, // time to live, default is one hour
});
}, 1000)
})
})