Add extra validity checking to MemcachedStore

These are the cpp-common changes that are part of https://github.com/Metaswitch/sprout/pull/810.