hotfix(db) cache_key was not always calculated correctly (#3831)
hotfix(db) cache_key was not always calculated correctly (#3831)

### Summary

Fixes issue that was in some cases, e.g. with `ACLs` leading to `nil` cache key, with requests like:
```
http put :8001/consumers/demo/acls/group
```

Also makes it consistent to always use `entity_to_insert|update|upsert` as it was sometimes using just `entity`(which might be lacking autogenerated `id` for example).
Kong/kong,Kong/kong,Kong/kong,Mashape/kong