Open gurre opened 5 years ago
I've looked into that before, but sadly there's no way to measure how much memory the stored data interface{}
occupies:
For instance, if x is a slice, Sizeof returns the size of the slice descriptor, not the size of the memory referenced by the slice
The most sensible solution would be to serialize everything to []byte
using encoding/gob
.
When a system is under high load the cache might grow to the point when it's consuming all available memory on the system it's running.
Consider adding some kind of upper limit to how much resources are occupied e.g. max items or max memory used. Memory usage could be calculated for structs using
unsafe.Sizeof
if the security requirements are accepting.