Description
In Drupal we want to deal with the problem that some services are bound to the database, for example a lock service. Per default this is using the database but you might want to use something else.
You can for sure always write a compiler pass and replace the service with one for your wanted backend like redis (just as example). This is quite annoying if you as a developer have a lot of services, or you just want to switch the storage as site administrator.
We came up with a schema which basically allows you to set a tag on these services (https://www.drupal.org/node/2302617). A pass will then try to look up "$backend.$service" services, with $backend being a configurable container parameter. This for example allows us to write mysql specific optimizations into "mysql.$service".
I wonder whether you are interested in a generic functionality. Given the structure I guess this should be part of some bundle, so it is not reusable but at least we would have a common functionality.