cache icon indicating copy to clipboard operation
cache copied to clipboard

cache rewrite

Open HopeBaron opened this issue 2 years ago • 4 comments

This PR is to:

  • Implement indexing for cache items in kord
  • Reflection-free implementation
  • Introduce a obverver-like relationship on discards instead of descriptions

HopeBaron avatar Apr 06 '23 14:04 HopeBaron

could you provide some examples how you think this all should be used (maybe also compared to the old cache api)? that way it will be easier to review because i would know what i'm looking at and what the intention was.

lukellmann avatar Apr 14 '23 12:04 lukellmann

@Lukellmann https://gist.github.com/HopeBaron/8417dbbbfa814be381b8c8498f4ba534 Above is a full example output:

{SnowflakeSetIndex(snowflakes=[1, 123])=MemberData(guildId=1, userId=123)}
{SnowflakeSetIndex(snowflakes=[123])=UserData(userId=123)}
{}
{}

HopeBaron avatar Apr 14 '23 13:04 HopeBaron

what i just realized is a problem with Cache.filter and Cache.firstOrNull: these will always have O(n) complexity because all objects have to be accessed to be filtered.

lukellmann avatar Apr 17 '23 10:04 lukellmann

Yeah but the implementation doesn't specify a Key no more if you are looking for something you can identify you can easily add that sort of data to your key. Create a key out of it, and get it.

HopeBaron avatar Apr 17 '23 11:04 HopeBaron