I'm working on a solution that contains 4 projects and I'd like to share the same dependency injection pattern.
The projects
Project A: MVC project with views and controllers that use DI.
Project B: WebAPI project with controllers that use DI.
Project C: Cache project, the layer that allow me to store and retrieve data in the cache memory.
Project D: Services project, the layer of services that store and retrieve data in database (and in cache).
Project A and project B refer to project D. (ex. They ask to the service layer the data and it gives them the data retrieved from database or from cache). (*project A and project B have IServiceManager injected in each controller constructor*).
Project D refers to project C because sometimes it needs data from cache memory and when it updates records on database, it purges the cache. (it has a ICacheManager injected in the constructor).
The problem
Project A and project B use the same way to retrieve and store data: they have a IServiceManager injected in the constructor for each controller and they call the ServiceManager method.
But when project B write a record on database (using the ServiceManager that should write on db and purge the cache), and then project A read data (using ServiceManager), project A continues to "see" old data stored in cache.
Expectations
I'd like that DI gives to project A and project B the same objects (same service and same cache manager) so they can work on the same data.
Is it possible? How can I "centralize" a DI pattern used by A and B in the same way that gives the same data?