Skip to content

Latest commit

History

99 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

TagCache.Redis

.Net Redis Cache with support for tagging

To allow detection of cache expiry, configure redis with

config set notify-keyspace-events Ex

##Features

  • Simple key value caching
  • Cache item expiry
  • Store cache items with tags
  • Retrieve cache items by tag
  • Remove all items by tag
  • Multiple Serialization options
  • Basic logging interface

Usage

NuGet

PM> Install-Package TagCache.Redis

Configuration

Any unset properties will use default values

varconfig=newCacheConfiguration(){RootNameSpace="_RedisCache",Serializer=newBinarySerializationProvider(),RedisClientConfiguration=newRedisClientConfiguration(){Host="localhost",DbNo=0,TimeoutMilliseconds=500}};varcache=newRedisCacheProvider(config);

No Configuration

varcache=newRedisCacheProvider();// will default to localhost

Adding Items

Add an item without tags

stringkey="TagCacheTests:Add";Stringvalue="Hello World!";DateTimeexpires=newDateTime(2099,12,11);cache.Set(key,value,expires);

Add an item with tags

stringkey="TagCacheTests:Add";Stringvalue="Hello World!";DateTimeexpires=newDateTime(2099,12,11);vartags=newList<string>{"tag1","tag2","tag3"};cache.Set(key,value,expires,tags);

Get Items

Get an item by key

vartest=cache.Get<String>("mykey");

Get items by tag

varresults=cache.GetByTag<String>("tag2");

Remove items

Remove item by key

cache.Remove("key1");
cache.Remove(newstring[]{"key2","key3"});

Remove items by tag

cache.RemoveByTag("tag1");

Logging

varcache=newRedisCacheProvider();cache.Logger=newMyLogger();// MyLogger : IRedisCacheLogger

About

.Net Redis Cache with support for tagging

Resources

Stars

8 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages