#discord #discord-api #twilight

yanked sparkle-cache

A backend-agnostic Discord cache implementation for the Twilight ecosystem

0.14.1 Dec 6, 2022
0.14.0 Nov 18, 2022
0.13.21 Nov 6, 2022
0.13.19 Oct 17, 2022
0.13.7 Sep 28, 2022

#26 in #twilight

Download history 1/week @ 2023-08-01 22/week @ 2023-08-15 23/week @ 2023-08-22 22/week @ 2023-09-05 22/week @ 2023-09-12 2/week @ 2023-10-24 28/week @ 2023-10-31 23/week @ 2023-11-07

53 downloads per month
Used in sparkle-cache-postgres

ISC license

2.5K SLoC

Sparkle Cache

GitHub crates.io docs.rs

A backend-agnostic Discord cache implementation for the Twilight ecosystem

It provides a Cache trait that provides methods to get data from the cache and a Backend trait used to add support for a backend, refer to the documentation of each trait for more


This crate is for adding support for a backend, if you just need to use the cache, you should use one of the crates:


The models don't use any arrays and every field is a primitive type, this makes it compatible with schematic backends out of the box


Only the data from events are cached, though it's on the to-do list to add support for data that requires API methods

This means this data can't be cached for now:

  • Private channels
  • Bans
  • Auto moderation rules
  • Integrations
  • Scheduled events
  • Invites
  • Webhooks
  • Missing data that you can create a PR to add to this list

Support for libraries other than Twilight

This doesn't depend tightly on Twilight, you can easily fork this and change the Twilight models used in it


Because it tries to follow Twilight's version, minor versions will include breaking changes. This means you should pin it to the latest version. For example instead of sparkle-cache = "0.14" do sparkle-cache = "0.14.0". Of course try to keep it at the latest version as updates usually contain bugfixes



Enables the testing module, it's intended for libraries implementing traits in this library, and it should be enabled only under [dev-dependencies], for example

name = "sparkle-cache-some-backend"
sparkle-cache = { version = "x", features = ["tests"] }
sparkle-cache = "x"

If the test error is related to this crate, please create an issue

Stickers are currently not cached as they can't be tested because of a bug in Twilight

Your help is needed

Any feedback or bug reports will be very useful in further development, the code is in a working state with all essential methods done but there's many possible additions that will be added as you request them!


~177K SLoC