Skip to content

Stateful extensible caching system #6

@Bluenix2

Description

@Bluenix2

Summary

So far there has been no gateway caching except for this poor start. The plan is to finish all models (#4) and then make them stateful (#4 (comment)) with knowledge about the RESTClient and this shared cache.

Description

There should be an extensible caching system in Wumpy that the user can hook into to optimize their data structures. An example where this would've been useful is when Python Discord created a ring buffer to improve cross-channel lookup of deleted messages, seen here.

Another benefit is the ease of injecting model subclasses - this has been the plan all along and can be seen in cache start linked above with the cls kwarg to store_user() and store_channel() methods. There's no way to update the typings for the user when they create these subclasses (and for example add new methods) - but that is not blocker and there's workarounds.

One last thing I want this to accomplish is to allow storing objects elsewhere like in Redis or shared-memory SQLite - but that gets complicated quickly as all cache methods need to become coroutine-functions which means that they can't be used inside the __init__() of models. To start with having all cache methods be sync would at least allow shared-memory SQLite to be used.

Tasks

  • Add abstract cache ABC with all methods used by the library.
  • Create default implementation with appropriate data structures for most use-cases.
  • Allow subclasses or completely unrelated implementations of the ABC to be hooked into the library.
  • Evaluate whether asynchronous cache implementations are possible or if they should just be left to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ⚙️ - In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions