gigsalad / node-redis-scan Goto Github PK
View Code? Open in Web Editor NEWA simple ES6 Redis key space scanning library.
License: Apache License 2.0
A simple ES6 Redis key space scanning library.
License: Apache License 2.0
It would be useful in some contexts to have an option for limiting the scan. At times we only want to scan until returning the first matching key or the first n
matching keys. This would lend itself to scan()
as well as eachScan()
(plus the specific variants of these).
Similar functionality could be achieved if the client is able to cancel any scan in progress though this approach would only lend itself to eachScan()
.
Hey!
I'm trying to use the scanner.scan to make a route that shows all the keys of my redis, but the problem is that the scan does not populate my array even when I use the await before it.
Am I trying to use it wrong?
The code:
`public async getAll(): Promise< any > {
let allData: string[] = [];
let test = await scanner.scan('*', (err: any, match: string[]) => {
if(err) throw(err);
console.log(match); // This log returns the correct data but only after the route is already closed.
return match;
});
console.log(test); // This log return an empty array.
return allData;
}`
Appreciate your help!
It would be nice to support SSCAN, HSCAN and ZSCAN. The API is the same so it would be just changing the method name to hscan
for example.
Related: https://redis.io/commands/scan
async function scan() {
const client = await getRedisClient();
const redisScan = require("node-redis-scan");
const scanner = new redisScan(client);
scanner.scan("*", (err, matchingKeys) => {
console.log("test");
});
}
Doesn't output "test" at all. The redisclient is working fine in other methods.
Running scan 0 match * prints out all of the keys in redis.
This would likely lead to a new 2.x release for this library which might not be backwards compatible with Node Redis clients of version 3.x. It would depend on whether there is a clean way to differentiate between client instance types. Something to look into.
I'm also not sure how useful this would be given Node Redis 4.x supports scan iterators now. One use might be in providing methods which return all of the gathered values at once, which would be less verbose/cumbersome than writing iterator loops every time you want to scan and could be preferable, given the context. ๐ค
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.