Interface INonUniqueIndex<TItem, TKey>
- Namespace
- RentADeveloper.AutoIndexCache
- Assembly
- RentADeveloper.AutoIndexCache.dll
Represents a non-unique index for cached items of the type TItem.
public interface INonUniqueIndex<out TItem, TKey> where TItem : class
Type Parameters
TItemThe type of cache items indexed by the index.
TKeyThe type of keys in the index.
Methods
ContainsKey(TKey?)
Determines whether this index contains the specified key.
bool ContainsKey(TKey? key)
Parameters
keyTKeyThe key to check.
Returns
- bool
True if this index contains the specified key; otherwise, false.
Examples
var cache = new AutoIndexCache();
cache.SetItemsLoader<User>(this.LoadUsers);
var hasGroup1Users = cache.Items<User>().NonUniqueIndex(a => a.GroupId).ContainsKey(1);
Exceptions
- ItemsLoaderReturnedNullException
The cache items loader for the cache item type
TItemhas returned a null reference instead of a list of cache items.- ItemsLoaderFailedException
The cache items loader for the cache item type
TItemhas thrown an exception.- ItemsAccessedFromInsideItemsLoaderException
An attempt was made to access cache items of the type
TItemfrom inside the cache items loader for that cache item type.
GetItems(TKey?)
Gets all cached items of the type TItem that have the specified key.
IReadOnlyList<out TItem> GetItems(TKey? key)
Parameters
keyTKeyThe key of the cache items to get.
Returns
- IReadOnlyList<TItem>
A read-only list of cached items of the type
TItemthat have the specified key.
Examples
var cache = new AutoIndexCache();
cache.SetItemsLoader<User>(this.LoadUsers);
var usersOfGroup1 = cache.Items<User>().NonUniqueIndex(a => a.GroupId).GetItems(1);
var activeUsersOfGroup10 = cache.Items<User>().NonUniqueIndex(a => new { a.IsActive, a.GroupId}).GetItems(new { IsActive = true, GroupId = 10 });
Exceptions
- ItemsLoaderReturnedNullException
The cache items loader for the cache item type
TItemhas returned a null reference instead of a list of cache items.- ItemsLoaderFailedException
The cache items loader for the cache item type
TItemhas thrown an exception.- ItemsAccessedFromInsideItemsLoaderException
An attempt was made to access cache items of the type
TItemfrom inside the cache items loader for that cache item type.
GetKeys()
Gets the keys in this index.
IReadOnlyCollection<TKey?> GetKeys()
Returns
- IReadOnlyCollection<TKey>
A read-only collection of the keys in this index.
Examples
var cache = new AutoIndexCache();
cache.SetItemsLoader<User>(this.LoadUsers);
var distinctGroupIds = cache.Items<User>().NonUniqueIndex(a => a.GroupId).GetKeys();
Exceptions
- ItemsLoaderReturnedNullException
The cache items loader for the cache item type
TItemhas returned a null reference instead of a list of cache items.- ItemsLoaderFailedException
The cache items loader for the cache item type
TItemhas thrown an exception.- ItemsAccessedFromInsideItemsLoaderException
An attempt was made to access cache items of the type
TItemfrom inside the cache items loader for that cache item type.