Implement general purpose cache_key function

This includes the non-instance logic from instance_cache_key. In addition
a warning is emitted for types that do not implement the __getstate__ method
for pickling.

Fix #258

Signed-off-by: Byron Ruth <b@devel.io>
`instance` is a model instance, not a string. The value of `version` could be an `int`, so the first check confirms it's a string before being passed into `hasattr` to test whether the it is a property name on the instance.