discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
992 stars 236 forks source link

Add legacy cache wrapper #1189

Closed SQKo closed 10 months ago

SQKo commented 10 months ago

Another attempts to solve huge memory in v10 cache. This brings back the Collection (in-memory) caching behavior that used to exists in v7 and prior. While not 100% the same, this reduce one layer of abstraction to the cache interface.

To use on all repository, the option needs to be set null like this:

'cache' => [
    AbstractRepository::class => null,
]

Or you can selectively choose the repository class, but I don't recommend mixing both ReactPHP's cache interface (including ArrayCache) with this way, unexpected behavior may happen.

I don't have big enough data to compare, but it is 18.8 MB vs 20.9 MB

BC: CacheWrapper no longer exposes interface object to public, use the CacheConfig to get the interface Discord::getCacheConfig() may returns null now

Tested