Class CacheStore
Represents an efficient in-memory cache of expiring optionally-prioritized objects.
This class is highly optimized for caching of business objects in data store implementations and does not guarantee that
all hash collisions are handled, that is - some data may be overridden. The implementation relies on 2 stage hashing, where the second collision replaces the
existing item with the colliding one if items are equal in their priorities. The degree of collisions is controlled by 'bucketSize' and 'recPerPage' parameters that
are passed to the store per table, so basically the tables are capped at a certain size and can not change (bucketSize*recPerPage).
The lookup implementation is 100% lock-free, whereas the degree of mutability-related locking is controlled by 'lockCount' per table.
This class is thread safe for reading and writing cache items, however it does not guarantee instant read/write consistency between threads.
Inheritance
System.Object
CacheStore
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Azos.dll
Syntax
public sealed class CacheStore : ApplicationComponent, IDisposable, IApplicationComponent, INamed, IConfigurable, IInstrumentable, IExternallyParameterized
Constructors
CacheStore(IApplicationComponent)
Declaration
public CacheStore(IApplicationComponent director)
Parameters
CacheStore(IApplicationComponent, String)
Declaration
public CacheStore(IApplicationComponent director, string name)
Parameters
CacheStore(IApplication)
Declaration
public CacheStore(IApplication app)
Parameters
CacheStore(IApplication, String)
Declaration
public CacheStore(IApplication app, string name)
Parameters
Fields
CONFIG_CACHE_SECTION
Declaration
public const string CONFIG_CACHE_SECTION = "cache"
Field Value
Type |
Description |
System.String |
|
CONFIG_STORE_SECTION
Declaration
public const string CONFIG_STORE_SECTION = "store"
Field Value
Type |
Description |
System.String |
|
CONFIG_TABLE_SECTION
Declaration
public const string CONFIG_TABLE_SECTION = "table"
Field Value
Type |
Description |
System.String |
|
Properties
ComponentLogTopic
Declaration
public override string ComponentLogTopic { get; }
Property Value
Type |
Description |
System.String |
|
Overrides
Count
Returns total number of records in all tables in the store
Declaration
public int Count { get; }
Property Value
Type |
Description |
System.Int32 |
|
DefaultTableOptions
Sets default options for a table which is not found in TableOptions collection.
If this property is null then every table assumes the set of constant values defined in Table class
Declaration
public TableOptions DefaultTableOptions { get; set; }
Property Value
ExternalParameters
Returns named parameters that can be used to control this component
Declaration
public IEnumerable<KeyValuePair<string, Type>> ExternalParameters { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Type>> |
|
InstrumentationEnabled
When true, emits instrumentation messages
Declaration
[Config]
[ExternalParameter(new string[]{"cache", "instrumentation"})]
public bool InstrumentationEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Item[String]
Returns a table by its name creating its' instance if such table is not in the set. Table names are case-insensitive
Declaration
public Table this[string table] { get; }
Parameters
Type |
Name |
Description |
System.String |
table |
|
Property Value
Item[String, UInt64]
Returns a cached record from named table identified by the key or null if this item was not found
Declaration
public CacheRec this[string table, ulong key] { get; }
Parameters
Type |
Name |
Description |
System.String |
table |
|
System.UInt64 |
key |
|
Property Value
Name
Returns store name which can be used to identify stores in registries and instrumentation/telemetry outputs
Declaration
public string Name { get; }
Property Value
Type |
Description |
System.String |
|
ParallelSweep
When enabled, uses parallel execution while sweeping tables, otherwise sweeps sequentially (default behavior)
Declaration
[Config]
[ExternalParameter(new string[]{"cache"})]
public bool ParallelSweep { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
TableOptions
Returns table options - used for table creation
Declaration
public Registry<TableOptions> TableOptions { get; }
Property Value
Tables
Returns all tables that this store currently contains
Declaration
public IRegistry<Table> Tables { get; }
Property Value
Methods
Configures store from node, if node==null then store will be configured by named node of 'app/cache/store[name=X]' path, if such path
is not found the store tries to find 'app/cache/store[!name]' (node without name)
Declaration
public void Configure(IConfigSectionNode node)
Parameters
Destructor()
Declaration
protected override void Destructor()
Overrides
DropTable(String)
Drops table by name returning true if it was found and removed
Declaration
public bool DropTable(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Boolean |
|
ExternalGetParameter(String, out Object, String[])
Gets external parameter value returning true if parameter was found
Declaration
public bool ExternalGetParameter(string name, out object value, params string[] groups)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Object |
value |
|
System.String[] |
groups |
|
Returns
Type |
Description |
System.Boolean |
|
ExternalParametersForGroups(String[])
Returns named parameters that can be used to control this component
Declaration
public IEnumerable<KeyValuePair<string, Type>> ExternalParametersForGroups(params string[] groups)
Parameters
Type |
Name |
Description |
System.String[] |
groups |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Type>> |
|
ExternalSetParameter(String, Object, String[])
Sets external parameter value returning true if parameter was found and set
Declaration
public bool ExternalSetParameter(string name, object value, params string[] groups)
Parameters
Type |
Name |
Description |
System.String |
name |
|
System.Object |
value |
|
System.String[] |
groups |
|
Returns
Type |
Description |
System.Boolean |
|
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
Implements
System.IDisposable
Extension Methods