Class CacheProperty
Represents a cache property that needs to be set, replaced, or removed for the current service.
Inheritance
Inherited Members
Namespace: Nevatech.Vsb.Repository.Processing
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class CacheProperty : IValidator, IEquatable<CacheProperty>
Constructors
CacheProperty()
Declaration
public CacheProperty()
Fields
CachePropertyNameFormat
Regular expression used for validating a cache property name.
Declaration
public static readonly Regex CachePropertyNameFormat
Field Value
Type | Description |
---|---|
System.Text.RegularExpressions.Regex |
ElementName
Name of the root element when object is serialized to XML.
Declaration
public const string ElementName = "PROPERTY"
Field Value
Type | Description |
---|---|
System.String |
Properties
CacheSeconds
Gets or sets the number of seconds to keep the value in cache.
Declaration
public string CacheSeconds { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ErrorMessage
Gets the summary of validation errors populated by the call to Validate() method.
Declaration
public string ErrorMessage { get; }
Property Value
Type | Description |
---|---|
System.String |
KeepExpirationIfExists
Gets or sets the flag indicating that property expiration must not be extended (reset), if property already exists in the cache. Default is false.
Declaration
public bool KeepExpirationIfExists { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Name
Gets or sets the property name.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Value
Gets or sets the static property value. If set to Null then existing property will be deleted.
Declaration
public string Value { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
Equals(CacheProperty)
Determines whether the specified object is equal to the current object.
Declaration
public bool Equals(CacheProperty other)
Parameters
Type | Name | Description |
---|---|---|
CacheProperty | other | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | True, if objects are equal. False, if objects are not equal. |
Equals(Object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | True, if objects are equal. False, if objects are not equal. |
Overrides
Get(Guid, String, Boolean)
Retrieves the value of the specified property from the cache.
Declaration
public static string Get(Guid serviceVersionKey, string propertyName, bool updateExpiry = false)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | serviceVersionKey | Key of the service version this property belongs to. |
System.String | propertyName | Property name. |
System.Boolean | updateExpiry | True to update existing key expiry to a new value (sliding expiration). The default value is false. |
Returns
Type | Description |
---|---|
System.String | Property value. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Hash code of the current instance. |
Overrides
GetOrSet<T>(Guid, String, Func<T>, Func<T, T>, Nullable<TimeSpan>, Boolean)
Retrieves, stores, or updates the specified property in the cache.
Declaration
public static T GetOrSet<T>(Guid serviceVersionKey, string propertyName, Func<T> createValue = null, Func<T, T> updateValue = null, TimeSpan? duration = default(TimeSpan? ), bool updateExpiry = true)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | serviceVersionKey | Key of the service version this property belongs to. |
System.String | propertyName | Property name. |
System.Func<T> | createValue | A method returning a new value for caching that is invoked, if cache entry is not found. |
System.Func<T, T> | updateValue | A method returning an updated value for caching that is invoked if existing cache entry is found. |
System.Nullable<System.TimeSpan> | duration | After the timeout has expired, the property will automatically be deleted. Setting this value to null will remove the timeout (make property persistent). |
System.Boolean | updateExpiry | True to update existing key expiry to a new value (reset expiration). The default value is true. |
Returns
Type | Description |
---|---|
T | Property value. |
Type Parameters
Name | Description |
---|---|
T | Type of the stored value. |
Remove(Guid, String)
Removes the specified property from the cache.
Declaration
public static void Remove(Guid serviceVersionKey, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | serviceVersionKey | Key of the service version this property belongs to. |
System.String | propertyName | Property name. |
Set(Guid, String, String, Nullable<TimeSpan>, Boolean)
Stores the provided property value in the cache.
Declaration
public static void Set(Guid serviceVersionKey, string propertyName, string propertyValue, TimeSpan? duration, bool updateExpiry = true)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | serviceVersionKey | Key of the service version this property belongs to. |
System.String | propertyName | Property name. |
System.String | propertyValue | Property value. |
System.Nullable<System.TimeSpan> | duration | After the timeout has expired, the property will automatically be deleted. Setting this value to null will remove the timeout (make property persistent). |
System.Boolean | updateExpiry | True to update existing key expiry to a new value (reset expiration). The default value is true. |
ToString()
Returns string representation of the object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representing the object's content. |
Overrides
Validate()
Evaluates the state of this object.
Declaration
public bool Validate()
Returns
Type | Description |
---|---|
System.Boolean | True if state is valid; otherwise, false. |