Class Table
Represents a table that stores cached items identified by keys
Inheritance
Implements
Inherited Members
Namespace: Azos.Data.Access.Cache
Assembly: Azos.dll
Syntax
public sealed class Table : INamed
Fields
BUCKET_COUNT_DEFAULT
Declaration
public const int BUCKET_COUNT_DEFAULT = 25111
Field Value
Type | Description |
---|---|
System.Int32 |
MAX_AGE_SEC_DEFAULT
Declaration
public const int MAX_AGE_SEC_DEFAULT = 300
Field Value
Type | Description |
---|---|
System.Int32 |
MAX_AGE_SEC_MINIMUM
Declaration
public const int MAX_AGE_SEC_MINIMUM = 5
Field Value
Type | Description |
---|---|
System.Int32 |
REC_PER_PAGE_DEFAULT
Declaration
public const int REC_PER_PAGE_DEFAULT = 7
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
BucketCount
Returns how many slots/buckets are pre-allocated per table, the higher the number the more memory will be reserved at table construction time, every slot is a reference (4 bytes on 32bit systems, 8 bytes on 64bit). For optimal performance this number should be around 75% of total record count stored in the table (table load factor).
Declaration
public int BucketCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
BucketPageLoadFactor
Returns the ratio of how many buckets are loaded with pages vs. bucket count
Declaration
public double BucketPageLoadFactor { get; }
Property Value
Type | Description |
---|---|
System.Double |
Capacity
Returns the maximum number of items that this table can hold at any given time given that no items will have any key hash collisions
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Count
Returns item count in the table
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
LockCount
Returns how many locks can be used for thread coordination during table changes
Declaration
public int LockCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
MaxAgeSec
Gets/sets maximum age of items in the table expressed in seconds. After this age is exceeded, the system will delete entries. The system does not guarantee that items will expire right on time, however it does guarantee that items will be available for at least this long.
Declaration
public int MaxAgeSec { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
Returns table name which is a unique string within the cache store
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
PageCount
Returns page count in the table
Declaration
public int PageCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ParallelSweep
When enabled, uses parallel execution while sweeping table buckets, otherwise sweeps sequentially (default behavior)
Declaration
public bool ParallelSweep { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
RecPerPage
Returns how many slots are pre-allocated per table's bucket(page) when more than one item produces hash collision. The higher the number, the more primary hash collisions can be accomodated by re-hashing on pages (secondary hash table within primary buckets)
Declaration
public int RecPerPage { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
StatComplexHitCount
Returns hit count stats for using complex keys
Declaration
public int StatComplexHitCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
StatComplexMissCount
Returns miss count stats for using complex keys
Declaration
public int StatComplexMissCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
StatHitCount
Returns hit count stats
Declaration
public int StatHitCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
StatMissCount
Returns miss count stats
Declaration
public int StatMissCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Store
Returns the store instance that this table is a part of
Declaration
public CacheStore Store { get; }
Property Value
Type | Description |
---|---|
CacheStore |
Methods
Get(UInt64, Int32)
Retrieves an item from this table by key where item age is less or equal to requested, or null if it does not exist
Declaration
public CacheRec Get(ulong key, int ageSec = 0)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | key | Item key |
System.Int32 | ageSec | Age of item in seconds, or 0 for any age |
Returns
Type | Description |
---|---|
CacheRec |
GetOrPut<TContext>(UInt64, Func<String, UInt64, TContext, Object>, TContext, Int32, Int32, Int32, Nullable<DateTime>)
Retrieves an item from this table by key where item age is less or equal to requested, or calls the itemFactory function and inserts the value in the store
Declaration
public CacheRec GetOrPut<TContext>(ulong key, Func<string, ulong, TContext, object> valueFactory, TContext factoryContext = null, int ageSec = 0, int putMaxAgeSec = 0, int putPriority = 0, DateTime? putAbsoluteExpirationUTC = default(DateTime? ))
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | key | Item key |
System.Func<System.String, System.UInt64, TContext, System.Object> | valueFactory | A function that returns new value for the specified tableName, key, and context |
TContext | factoryContext | An object to pass into the factory function if it gets invoked |
System.Int32 | ageSec | Age of item in seconds, or 0 for any age |
System.Int32 | putMaxAgeSec | MaxAge for item if Put is called |
System.Int32 | putPriority | Priority for item if Put is called |
System.Nullable<System.DateTime> | putAbsoluteExpirationUTC | Absolute expiration UTC timestamp for item if Put is called |
Returns
Type | Description |
---|---|
CacheRec |
Type Parameters
Name | Description |
---|---|
TContext | A type of item factory context |
Put(UInt64, Object, out CacheRec, Int32, Int32, Nullable<DateTime>)
Puts a key-identified item into this table. If item with such key is already in this table then replaces it and returns false, returns true otherwise
Declaration
public bool Put(ulong key, object value, out CacheRec rec, int maxAgeSec = 0, int priority = 0, DateTime? absoluteExpirationUTC = default(DateTime? ))
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | key | Item's unique key |
System.Object | value | Item |
CacheRec | rec | Returns new or existing CacheRec |
System.Int32 | maxAgeSec | For how long will the item exist in cache before it gets swept out. Pass 0 to use table-level setting (default) |
System.Int32 | priority | Items priority relative to others in the table used during collision resolution, 0 = default |
System.Nullable<System.DateTime> | absoluteExpirationUTC | Sets absolute UTC time stamp when item should be swept out of cache, null is default |
Returns
Type | Description |
---|---|
System.Boolean |
Put(UInt64, Object, Int32, Int32, Nullable<DateTime>)
Puts a key-identified item into this table. If item with such key is already in this table then replaces it and returns false, returns true otherwise
Declaration
public bool Put(ulong key, object value, int maxAgeSec = 0, int priority = 0, DateTime? absoluteExpirationUTC = default(DateTime? ))
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | key | Item's unique key |
System.Object | value | Item |
System.Int32 | maxAgeSec | For how long will the item exist in cache before it gets swept out. Pass 0 to use table-level setting (default) |
System.Int32 | priority | Items priority relative to others in the table used during collision resolution, 0 = default |
System.Nullable<System.DateTime> | absoluteExpirationUTC | Sets absolute UTC time stamp when item should be swept out of cache, null is default |
Returns
Type | Description |
---|---|
System.Boolean |
Remove(UInt64)
Removes a key-identified item from the named table returning true when item was deleted or false when item was not found
Declaration
public bool Remove(ulong key)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | key |
Returns
Type | Description |
---|---|
System.Boolean |