[engine] Construct cache_key based on class name

To distinguish between an object or a collection containing one object,
add the class name to the cache key.