question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis Fix - namespace key can grow to GB size

See original GitHub issue

Describe the bug Since I migrated to keyv it looks like the amount of freeable memory is declining in constant rate: https://imgur.com/a/77kOTD7 (20 Jul is when I released changes for keyv migration).

I expect it to be related to the namespace:... key, that in my case can grow to more than 15GB in actively used cache.

To Reproduce I would expect that adding a bunch of big keys for short living values will cause the namespace:... size to constantly grow.

Expected behavior I would expect to have some auto-purging mechanism?

Tests (Bonus!!!) N/A

Additional context N/A

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
KODerFunkcommented, Dec 6, 2022

I have another issue around this.redis.sadd(. I use commandTimeout option and some errors dont catch in project-code. As it turned out, these are timeouts on the sadd command. Until I figured out why my catch does not work and the error goes to unhandledRejection. I need the ability to disable this, I also have to make class MyKeyvRedis extends KeyvRedis in the project and override not only the set method, but also clear (remove smembers, add throw new MyError) and delete (remove srem).

2reactions
PhantomRaycommented, Nov 23, 2022

As a temporary workaround, I use the following code:

class MyKeyvRedis extends KeyvRedis {
  async set(key, value, ttl) {
    if (typeof value === 'undefined') {
      return Promise.resolve(undefined);
    }

    return Promise.resolve().then(() => {
      if (typeof ttl === 'number') {
        return this.redis.set(key, value, 'PX', ttl);
      }

      return this.redis.set(key, value);
    });
  }
}

As you can see, I removed this.redis.sadd(this._getNamespace(), key);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis: Show database size/size for keys - Stack Overflow
So my solution to my own problem: After playing around with redis-cli a bit longer I found out that DEBUG OBJECT <key> reveals...
Read more >
MEMORY USAGE - Redis
The MEMORY USAGE command reports the number of bytes that a key and its value require to be stored in RAM. The reported...
Read more >
Redis Namespace and Other Keys to Developing with Redis
For example: consider that storing 1,000,000 keys with Redis namespace, each set with a 32-character value, will consume about 96MB when using 6 ......
Read more >
Redis Keys Standard Naming Conventions. - W3schools.io
Redis keys standard naming conventions size, namespace, separator used for designing keys for better readable, maintainable, and faster lookups.
Read more >
[core] External Redis does not work for new clusters #17400
See https://discuss.ray.io/t/how-can-i-connect-to-pre-created-redis- ... you can increase /dev/shm size by passing '–shm-size=2.40gb' to 'docker run' (or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found