Implementing an efficient memory cache (or choosing an existing library)

Started by
-1 comments, last by Anfaenger 6 years, 11 months ago

Hi!

I'm writing a procedural voxel->polygon engine and I need to frequently generate/save/load and destroy chunks.

I'd like to avoid regenerating, and especially loading (== touching the disk) chunks, which have been recently used, by employing a memory cache.

Ideally, I'd like to reserve a fixed-size memory block for the 'chunk cache', address cached chunks by their IDs and specify chunk eviction policy/expiration time.

How to best implement such a cache? (i.e. fast and efficient, no fragmentation.)

Could you give me any references to existing implementations?

I found these libraries, but they seem too 'heavy' for my toy voxel engine:

http://cachelot.io/ and memcached

Is there anything more lightweight?

This topic is closed to new replies.

Advertisement