Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching Engines #10

Closed
viztea opened this issue Sep 22, 2020 · 1 comment
Closed

Caching Engines #10

viztea opened this issue Sep 22, 2020 · 1 comment
Labels
enhancement New feature or request needs discussion Whether this issue needs to be discussed more.

Comments

@viztea
Copy link
Contributor

viztea commented Sep 22, 2020

As of right now, neocord only has support for memory caching... I'd like to add ways to use different methods like redis, mongodb, or any other database. But I have no idea how to do so.

Setup?

This is how I would like it to look (typescript):

import { Client, DiscordStructure } from "neocord";
import { RedisDataEngine, Sweepers } from "@neocord/engines";

const client = new Client({
  data: {
    engines: [
      new RedisDataEngine({
        handles: new Set()
          .add(DiscordStructure.Message)
          .add(DiscordStructure.Presence)
        sweepers: {
          [DiscordStructure.Message]: Sweepers.Message({
            lifetime: "30m",
            interval: "5m"
          })
        }
      })
    ]
  }
});

So here we have imported the Client and DiscordStructure.

The DiscordStructure enum is used to identify structures that can be cached within neocord like a Message, Role, etc...

We have also imported the Redis Data Engine and the Sweepers object.

The sweepers object contains pre-made sweepers for some of the structures.

In this case the redis data engine caches messages/presences and everything else will be stored within memory. I've also declared the sweepers option, only enabling a message sweeper which gets ran every 5 minutes and checks whether the message is older than 30 minutes and if it is it will be removed from the redis cache.


This is all just a very cool concept that might come to life but until there are more contributors this wont happen for quite a while.

@viztea viztea added the enhancement New feature or request label Sep 22, 2020
@viztea viztea pinned this issue Sep 22, 2020
@viztea viztea added the needs discussion Whether this issue needs to be discussed more. label Sep 22, 2020
@viztea
Copy link
Contributor Author

viztea commented Sep 22, 2020

The internals of the caching is what I would really like help on, I have no ideas on how this would work internally... especially with all of the different managers and stuff.

@viztea viztea closed this as completed Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion Whether this issue needs to be discussed more.
Projects
None yet
Development

No branches or pull requests

1 participant