Adds an item into the Cache object with a cache key to reference its location
and using default values provided by the CacheItemPriority enumeration. It also
enables the associating tags with the object.
Namespace: Alachisoft.NCache.Web.CachingAssembly: Alachisoft.NCache.Web (in Alachisoft.NCache.Web.dll) Version: 4.1.0.0 (4.1.0.0)
Syntax
C# |
---|
public CacheItemVersion Add( string key, Object value, Tag[] tags ) |
Visual Basic |
---|
Public Function Add ( _ key As String, _ value As Object, _ tags As Tag() _ ) As CacheItemVersion |
Visual C++ |
---|
public: CacheItemVersion^ Add( String^ key, Object^ value, array<Tag^>^ tags ) |
Parameters
- key
- Type: System..::..String
The cache key used to reference the item.
- value
- Type: System..::..Object
The item to be added to the cache.
- tags
- Type: array<Alachisoft.NCache.Runtime.Caching..::..Tag>[]()[][]
An array of Tag to associate with the object.
Return Value
An instance of CacheItemVersionRemarks
Note: If the key or value parameter is null, an ArgumentNullException is thrown.
Note: If exceptions are enabled through the ExceptionsEnabled setting, this property throws exception incase of failure.
Examples
The following example demonstrates how to add an item into an application's cache.
CopyC#
Cache cache = NCache.InitializeCache("myCache"); Tag[] tags = new Tag[1]; tags[0] = new Tag("tag-name"); cache.Add("DSN", connectionString, tags);
Exceptions
Exception | Condition |
---|---|
System..::..ArgumentNullException | key or value contains a null reference (Nothing in Visual Basic). |
System..::..ArgumentException | key or value is not serializable. |