https://github.com/pimbrouwers/johnnycache.net
A thread-safe caching abstraction for .NET
https://github.com/pimbrouwers/johnnycache.net
Last synced: 26 days ago
JSON representation
A thread-safe caching abstraction for .NET
- Host: GitHub
- URL: https://github.com/pimbrouwers/johnnycache.net
- Owner: pimbrouwers
- License: mit
- Created: 2016-02-09T02:35:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-08-26T17:18:22.000Z (over 8 years ago)
- Last Synced: 2025-02-10T03:41:50.990Z (3 months ago)
- Language: C#
- Homepage: http://johnny-cache.pimbrouwers.com
- Size: 29.9 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Johnny Cache
[](https://travis-ci.org/pimbrouwers/johnny-cache/)A thread-safe caching abstraction for .NET -- leverages object cache, filesystem and Azure Blob Storage (Amazon S3 coming soon). Johnny Cache was designed to improve application performance in both single-server and web-farm systems.
## Setup/Configuration
There are 3 primary configuration variables that need to be set in your ``App.Config/Web.Config``
```xml```
Note: None of the above configuration variables are required, as they all are backed by default return values;## Azure Configuration
To leverage Azure Blob Storage add the following keys to your ``App.Config/Web.Config``
```xml```
## Amazon S3 Configuration
```c#
throw new NotImplementedException("Coming Soon!");
```## Usage
The API for Johnny Cache is very simple, containing only 3 methods: ``Get()`` ``Set()`` ``Delete()``.
### Get
The ``Get()`` method will:
- Check Object Cache
- Check the File Dependancy
- Check External Providers (if configured, see above)The primary method parameter here is the ``key``. For "stale" checks you can optionally pass a ``cacheDurationSeconds`` param to override the library-governing expiration.
```c#
string cacheKey = "SomeUniqueCacheKey";
YourCoolObject mycoolObject = JohnnyCache.CacheIO.Get(cacheKey) as YourCoolObject; //using library expiration
YourCoolObject mycoolObject = JohnnyCache.CacheIO.Get(cacheKey, 6000) as YourCoolObject; //overriding library expiration
```
### Set
The ``Set()`` method will:
- Write to Object Cache
- Write to the File Dependancy
- Upload to External Providers (if configured, see above)The primary method parameter here is the ``key``. For "stale" checks you can optionally pass a ``cacheDurationSeconds`` param to override the library-governing expiration.
```c#
string cacheKey = "SomeUniqueCacheKey";
JohnnyCache.CacheIO.Set(myCoolObject, cacheKey); //using library expiration
JohnnyCache.CacheIO.Set(myCoolObject, cacheKey, 6000); //overriding library expiration
```
### Delete
The delete method will purge the object(s) from all levels of cache.The lone method parameter here is the ``key``.
```c#
string cacheKey = "SomeUniqueCacheKey";
JohnnyCache.CacheIO.Set(cacheKey);
```