Fix bugs when handling string keys

Cache synchronization doesn't work properly if using primary keys that are strings. This is because the "cache_read" and "cache_write" methods attempt to automagically infer whether to process a purported key by checking whether it is a string. If the primary key value already is a string, then it will not be processed into an actual cache key.

This can be fixed by removing the automatic processing from the two methods mentioned above, and always presenting those methods with properly formatted keys.

This pull request changes the expected behaviour of two private methods, necessitating a small refactor of three other private methods. Tests have been updated as well.