Tor.ObjectCache 1.0.4

A simple, lightweight, free object cache.

Install-Package Tor.ObjectCache -Version 1.0.4
dotnet add package Tor.ObjectCache --version 1.0.4
<PackageReference Include="Tor.ObjectCache" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tor.ObjectCache --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Usage:
The objects, what you want to cache, have to implement the ICacheable interface:

public class ClassA : ICacheable
{
    public object UniqueId { get; set; }

    public string Name { get; set; }
}

Create a cache:

var cache = new MixedObjectCache();

Add object to cache:

var classA = new ClassA() { UniqueId = 1, Name = "ClassA" };
cache.Add(classA);

Get object from cache:

var a = cache.GetObject<ClassA>(1);

Remove object from cache:

cache.RemoveObject<ClassA>(1);

Get all instances by type from cache:

var aList = cache.GetAllObject<ClassA>();

Clear instances from cache by a type:

cache.ClearCache<ClassA>();

Clear the entire cache:

cache.ClearCache();

Thread safety:
The cache is thread safe by default.

Usage:
The objects, what you want to cache, have to implement the ICacheable interface:

public class ClassA : ICacheable
{
    public object UniqueId { get; set; }

    public string Name { get; set; }
}

Create a cache:

var cache = new MixedObjectCache();

Add object to cache:

var classA = new ClassA() { UniqueId = 1, Name = "ClassA" };
cache.Add(classA);

Get object from cache:

var a = cache.GetObject<ClassA>(1);

Remove object from cache:

cache.RemoveObject<ClassA>(1);

Get all instances by type from cache:

var aList = cache.GetAllObject<ClassA>();

Clear instances from cache by a type:

cache.ClearCache<ClassA>();

Clear the entire cache:

cache.ClearCache();

Thread safety:
The cache is thread safe by default.

Release Notes

New cache settings:
- Expire: set the expire of the cached objects.
- AutoExpandExpireTime: automatically expands the expire time in every get of an object.

  • .NETStandard 2.0

    • No dependencies.

Version History

Version Downloads Last updated
1.0.4 179 4/27/2018
1.0.3 196 4/2/2018
1.0.2 198 3/27/2018
1.0.1 192 3/24/2018
1.0.0 189 3/24/2018