https://github.com/moattarwork/simplecache
https://github.com/moattarwork/simplecache
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/moattarwork/simplecache
- Owner: moattarwork
- Created: 2021-03-21T12:54:05.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-21T13:38:38.000Z (over 5 years ago)
- Last Synced: 2025-03-15T11:11:32.082Z (over 1 year ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SimpleCache
SimpleCache is a simple solution for caching. It's a library written in .net 5.0.
## How to use
The Unit test project explains different type of the usage for the Cache. Here are some samples from the usages:
```csharp
// Simple use
var cache = new Cache();
cache.Set("key 1", "Sample values");
cache.Set("key 2", "Sample other values");
var cachedValue = cache.Get("key 1");
// Cache with notification
var cache = new Cache(2, opt => { opt.OnItemEvicted = n => /* Handling of the notification*/ });
```
## Extension Points
- The implementation for locking is basic and it can be done using more effective lock such as ReaderWriterLockSlim.
- Having a GetOrAdd method (sync or async) will be helpful.