Skip to content

pimbrouwers/JohnnyCache.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Johnny Cache

Build Status

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

<!-- JOHNNY CACHE -->
<add key="JC-ObjectCacheName" value="JohnnyCache-SomeProject"/>
<add key="JC-WorkingDirectory" value="c:\temp\JohnnyCache\SomeProject"/>
<add key="JC-ExpirationInSeconds" value="300"/>

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

<add key="JC-AzureAccountName" value="{{YOUR ACCOUNT NAME}}"/>
<add key="JC-AzureAccountKey" value="{{YOUR ACCOUNT KEY}}"/>

Amazon S3 Configuration

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.

string cacheKey = "SomeUniqueCacheKey";
YourCoolObject mycoolObject = JohnnyCache.CacheIO.Get<YourCoolObject>(cacheKey) as YourCoolObject; //using library expiration
YourCoolObject mycoolObject = JohnnyCache.CacheIO.Get<YourCoolObject>(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.

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.

string cacheKey = "SomeUniqueCacheKey";
JohnnyCache.CacheIO.Set(cacheKey);

About

A thread-safe caching abstraction for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published