Skip to content

gegaryfa/RepositoryPatternWithAutoRefreshCache

Repository files navigation

Repository Pattern With Auto-Refresh Cache

license GitHub stars

.Net Core API - Repository pattern with auto refresh cache. This is a simple API using the repository design pattern to get data from a database. The data from the database are being cached either InMemory or in Redis(for scaled systems).

Getting Started

Clone the repo, open a terminal and run make to see all the possible actions. makefile

The project setup is based on Domain Driven Design: makefile

Prerequisites

Installing

I created a makefile to make it as easy as possible to get the docker containers up and runnig 😎. The only thing you need to do is run:

make up

After that you need to wait for the project to build and you are all set! The make command will run the docker-compose file and download all the images required for the porject. This will take some time so be patient ☕. When the make up command is finished, you should have 3 containers running:

  • The web API @: http://localhost:8000/
  • A SQL server with some dummy data already seeded in a database.
  • A redis cache which is being used when you set redis as the cache provider.

Alternatively, you can run the RepositoryWithCaching.WebApi project which will use In-memory(by default) data instead of a database on a sql server.

Built With

Sources

A good read on distributed caching for .Net Core: Distributed caching in ASP.NET Core.

Authors

  • George Garyfallou - Initial work - gegaryfa

Acknowledgments

  • Hat tip to anyone whose code was used