https://github.com/jmbl1685/aspnet-core-net-6-api-cache
ASP.NET Core (.NET 6) Web API + cache (Redis, Memory)
https://github.com/jmbl1685/aspnet-core-net-6-api-cache
aspnet-core cache cache-memory net-6 redis web-api
Last synced: about 1 year ago
JSON representation
ASP.NET Core (.NET 6) Web API + cache (Redis, Memory)
- Host: GitHub
- URL: https://github.com/jmbl1685/aspnet-core-net-6-api-cache
- Owner: jmbl1685
- Created: 2022-07-07T00:02:05.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-29T23:53:23.000Z (over 3 years ago)
- Last Synced: 2025-01-04T14:42:11.507Z (over 1 year ago)
- Topics: aspnet-core, cache, cache-memory, net-6, redis, web-api
- Language: C#
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ASP.NET Core (.NET 6) Web API with cache
To run this project from Docker
```sh
$> docker build -t aspnet-core-net-6-api-cache -f ./CacheSample.WebApi/Dockerfile .
$> docker create --name aspnet-core-net-6-api-cache-core aspnet-core-net-6-api-cache
$> docker start aspnet-core-net-6-api-cache-core
$> docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
```
Solution sample to (port is already allocated)
```
Bind for 0.0.0.0:3000 failed: port is already allocated.
$> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69e65c95dfaf aspnet-core-net-6-api-cache "dotnet CacheSample.…" 35 seconds ago Up 29 seconds aspnet-core-net-6-api-cache-core
$> docker stop 69e65c95dfaf
$> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$> docker run --rm -p 3000:3000 aspnet-core-net-6-api-cache
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://[::]:3000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
Content root path: /app/
```
#### Using Memory

#### Using Redis

You can add your custom DB Provider (MongoDB, SQL Server, PostgreSQL, etc) and adapt it as necessary
Go to the file "appsettings.json" (aspnet-core-net-6-api-cache/CacheSample.WebApi/appsettings.json) and replace your redis connection string
```
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Redis": {
"ConnectionString": "your_host:your_port,password=your_password"
}
}
```
## Screenshots:


## Result:
