userver
userver copied to clipboard
Implement caching component for MySQL database backend
There is a very nice to have PosgreCache component: one has to just make a policy of like 6 fields and everything auto-magically works.
Implementing the same was attempted for MySQL driver as well (see https://github.com/userver-framework/userver/pull/217/files#diff-c28867a7b5c4d7fd434d78ce0a948973678d2505db4cba0e789553fd31ae78de), but led to an immense amount of plain copy-paste (with more to come) and was dropped altogether.
Still, we would like to have a caching component for MySQL, and we believe this could be achieved via almost exclusively reusing what is already implemented for PostgreSQL.
A good starting point would be to decide, which part of the PostgreSQL policy are generic enough to be shared with MySQL (and keep other potential database backends in mind).
After that one could move shared parts somewhere here https://github.com/userver-framework/userver/tree/develop/core/include/userver/drivers (potentially renaming drivers
to storages
along the way) and start working on the actual implementation, which, from a distance, should be very compact due to massive reusing of the logic we already have in PostgreSQL cache.
I would recommend to share the overall design before jumping on the implementation, because this issue is better to be done in multiple steps, otherwise the PR could become too big and messy due to moving things around.
We don't expect to have all the logic from PostgreCache mirrored in MySQLCache (or whatever the name would be) in one go, but it should be easily extendable, please keep that in mind as well.