[Fixes #11512] improves cache size calculation in MemoryStore

* Takes the size of cache keys into account

* Takes per-entry overhead into account

* See https://github.com/rails/rails/issues/11512