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.

Easy way to declare custom Cache

See original GitHub issue

Summary

It would be nice if I could declare a cache class in CacheSettings. Currently you have to patch multiple things, including Bot._cache and Bot._event_manager._cache.

Why is this needed?

To add to or modify the default cache.

Ideal implementation

An extra setting in CacheSettings for cache class; it should expect a subclass of CacheImpl. Then it can set self._cache = cache_settings.cache_class(...), or something of the sort.

Checklist

  • I have searched the issue tracker and have made sure it’s not a duplicate. If it is a follow up of another issue, I have specified it.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ahnaf-zamilcommented, Jan 24, 2022

Yeah that’s what I said in the last part of my reply. The GatewayBot could take in a cache impl as a constructor arg, and then use that. But at the moment, it’s hardcoded to use hikari’s default CacheImpl, and the only way to change it is to override _cache and _event_manager._cache.

0reactions
FasterSpeedingcommented, Jan 24, 2022

For example, the current cache only stores existing values. What if I wanted to store None for deleted messages, so that I don’t fetch non-existing messages repeatedly?

BTW this example would likely fall under #880 (although it’d never quite apply to messages since that cache store is always incomplete)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tutorial: Creating a custom cache - HCL Product Documentation
Custom caches can take full advantage of the HCL Cache framework for caching locally and remotely ... Perform the following steps to create...
Read more >
How to Create a Simple In Memory Cache in Java (Best ...
Crunchify Java and J2EE Tutorials How to Create a Simple In Memory Cache in Java (Best Lightweight Java ... How to Create a...
Read more >
How to create a custom cache in Sitecore - Laub plus Co
The most basic usage of a custom cache is to use it for storing string values. Then you just call GetString and SetString...
Read more >
Create custom cache keys - Cloudflare Docs
Under Then the settings are, choose Custom Cache Key from the dropdown. Click the appropriate Query String setting. (Optional) Click Advanced and enter ......
Read more >
How to customize caches with Spring/ Spring Boot - Medium
We will implement a very simple (and dummy) cache and wire it to our business service. I used Kotlin as the implementation language...
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