Skip to content

Conversation

@j0x0j
Copy link

@j0x0j j0x0j commented Sep 8, 2017

The KEYS command is really expensive in production. With ~500 ops/sec latency for reads and writes was between 5-7 seconds. Using the SCAN command instead reduced latency to manageable sub-second levels.

/** Get a list of keys using the wildcard */
self.client.keys(prefix + ':' + name, domain.intercept(function (keys) {
if ( ! keys.length ) {
self.client.scan(0, 'match', prefix + ':' + name, domain.intercept(function (result) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are going to perform only one SCAN iteration which could return empty results set, so to find all matching keys you will need to repeat scanning till the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants