PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.SingleItemCache< T > Class Template Reference

SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL. More...

Inheritance diagram for PeanutButter.Utils.SingleItemCache< T >:
PeanutButter.Utils.ISingleItemCache< T >

Public Member Functions

 SingleItemCache (Func< T > generator, TimeSpan timeToLive)
 SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL.
 SingleItemCache (Func< T > generator, Func< bool > cacheInvalidator)
 SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided function to test if the cache should be invalidated before the each read.
void Invalidate ()
 Invalidates the cache such that the next call will definitely regenerate the value.

Properties

Value [get]
 The value for the generator, or a cached value, if available and still fresh enough.
Func< T > Generator [get]
 Expose the generator (might be useful for testing purposes)
TimeSpan TimeToLive [get]
 Expose the provided TimeToLive (might be useful for testing purposes)
Func< bool > CacheInvalidator [get]
 When provided via the alternative constructor.

Detailed Description

SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL.

Member Function Documentation

◆ Invalidate()

void PeanutButter.Utils.SingleItemCache< T >.Invalidate ( )

Invalidates the cache such that the next call will definitely regenerate the value.

Exceptions
NotImplementedException

Implements PeanutButter.Utils.ISingleItemCache< T >.

◆ SingleItemCache() [1/2]

PeanutButter.Utils.SingleItemCache< T >.SingleItemCache ( Func< T > generator,
Func< bool > cacheInvalidator )

SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided function to test if the cache should be invalidated before the each read.

Parameters
generator
cacheInvalidator

◆ SingleItemCache() [2/2]

PeanutButter.Utils.SingleItemCache< T >.SingleItemCache ( Func< T > generator,
TimeSpan timeToLive )

SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL.

Parameters
generator
timeToLive
Exceptions
NotImplementedException

Property Documentation

◆ Generator

Func<T> PeanutButter.Utils.SingleItemCache< T >.Generator
get

Expose the generator (might be useful for testing purposes)

Implements PeanutButter.Utils.ISingleItemCache< T >.

◆ TimeToLive

TimeSpan PeanutButter.Utils.SingleItemCache< T >.TimeToLive
get

Expose the provided TimeToLive (might be useful for testing purposes)

Implements PeanutButter.Utils.ISingleItemCache< T >.

◆ Value

T PeanutButter.Utils.SingleItemCache< T >.Value
get

The value for the generator, or a cached value, if available and still fresh enough.

Implements PeanutButter.Utils.ISingleItemCache< T >.


The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/SingleItemCache.cs