https://github.com/selcukgural/ramcache
RAMCache a simple cache in-memory for .Net applications
https://github.com/selcukgural/ramcache
cache cache-library caching dictionary
Last synced: 2 months ago
JSON representation
RAMCache a simple cache in-memory for .Net applications
- Host: GitHub
- URL: https://github.com/selcukgural/ramcache
- Owner: selcukgural
- Created: 2020-12-17T12:49:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-16T20:15:16.000Z (over 5 years ago)
- Last Synced: 2025-11-14T22:10:54.770Z (7 months ago)
- Topics: cache, cache-library, caching, dictionary
- Language: C#
- Homepage: https://www.selcukgural.com
- Size: 71.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
 RAMCache - a simple cache in-memory for .Net applications
========================================
RAMCache is a [NuGet library](https://www.nuget.org/packages/RAMCache) that you can add in to your .Net or .Net Core project.
`Install-Package RAMCache`
Basics
--------
Add a new entry with will delete when expire time is come. This mean, when entry expire time is come entry will be deleted. For this case expire time is 30 minutes.
```csharp
ramCache.Add(key, value, TimeSpan.FromMinutes(30));
```
or
```csharp
var key = "Barış Manço";
var value = "Nick the chopper";
cache.AddOrUpdate(key,value);
```
Getting value
```csharp
object val;
cache.Get(key, out val); //Nick the chopper
```
Examples
--------
###### Web Api example usage:
``` csharp
services.AddRAMCache(e => e.MaximumItemCount = 5000);
```
```csharp
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddRAMCache(e => e.MaximumItemCount = 5000);
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
```
Add RAMCache to services and you can use it by injecting
```csharp
private readonly IRAMCache _ramCache;
public WeatherForecastController(IRAMCache ramCache)
{
_ramCache = ramCache;
}
```
###### For other application types example usage:
```csharp
public static readonly RAMCache RamCache = new RAMCache(new RAMCacheServiceOptions{MaximumItemCount = 5000});
```