xna-cncnet-client icon indicating copy to clipboard operation
xna-cncnet-client copied to clipboard

Add map preview cache

Open SadPencil opened this issue 11 months ago • 6 comments

SadPencil avatar Jan 08 '25 03:01 SadPencil

Nightly build for this pull request:

github-actions[bot] avatar Jan 08 '25 04:01 github-actions[bot]

Actually hold on, maybe it would be better to use something like a weak reference for the cache instead of manually doing it?

Also I am not sure if clearing all of the maps when the limit is reached is a good idea, I would shave off the not used ones. Some maps are going to appear more frequently so they won't be deleted.

Thanks for letting me know WeakReference. Will investigate

SadPencil avatar Feb 02 '25 16:02 SadPencil

... I would shave off the not used ones. Some maps are going to appear more frequently so they won't be deleted.

LRU.

pzhlkj6612 avatar Feb 03 '25 21:02 pzhlkj6612

... I would shave off the not used ones. Some maps are going to appear more frequently so they won't be deleted.

LRU.

I would prefer leaving GC to decide using WeakReference

SadPencil avatar Feb 04 '25 05:02 SadPencil

No, he has a point. GC doesn't care about time of last use, but we do. LRU cache seems to be a common technique and an effective measure for keeping only actually used things in memory, so why not?

Metadorius avatar Feb 04 '25 09:02 Metadorius

No, he has a point. GC doesn't care about time of last use, but we do. LRU cache seems to be a common technique and an effective measure for keeping only actually used things in memory, so why not?

Okay. I just searched and find out WeakReference will be cleared out at every collection. Will implement an LRU

SadPencil avatar Feb 04 '25 10:02 SadPencil