Add Keyvaluestore header cache

Not sure it's a proper time to merge this big branch. Could wait for next release.

Mainly add header cache to KeyValueStore, in order to make header passed with shared_ptr, there exists many methods arguments needed to change.