Skip to content

leosul/MemoryCache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CachingApp

Build Status

The idea of ​​this package is to facilitate the use of memory cache, it is just an abstraction that helps the developer to add or remove data in memory, just by making use of an interface.

Dependencies

  • .NET6 or >
  • Microsoft.Extensions.Caching.Memory
  • Microsoft.Extensions.Configuration.Abstractions
  • Microsoft.Extensions.DependencyInjection.Abstractions

Installation

nuget CachingApp

Install-Package CachingApp -Version 1.0.0

How to use

Create a .json file in the root of your project with the name ${appsettings.json} and create a configuration:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Caching" : {
    "Customer" : "01:00:00"
  }
}

where the "Caching" node must contain the name and the time that the data will be in memory. To use the feature, just add it to the program.cs file

Capture

Example

Capture

inject ICacheStore in the controller's constructor, on line 23 instantiate the CacheKeyStore class passing the object you intend to put in memory, informing the cache key and the name previously registered in the appsettings.json file. On line 24 try to get the data in memory passing the key, on line 32 if there is no data in memory, it must be added. This way the data is already available in memory from the next request.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages