Keyvaluestore cache

Mainly add header cache to KeyValueStore, in order to make header passed with shared_ptr, there exists many methods arguments needed to change.
We probably want to remember it between calls to trim_cache to avoid always trying to trim the same EVICT_COUNT*COMPARE_COUNT items.