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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.4 388 4/27/2018
1.0.3 398 4/2/2018
1.0.2 406 3/27/2018
1.0.1 386 3/24/2018
1.0.0 422 3/24/2018