Export (0) Print
Expand All

Cache.Insert Method

Inserts an item into the Cache object. Use one of the versions of this method to overwrite an existing Cache item with the same key parameter.

Overload List

Inserts an item into the Cache object with a cache key to reference its location and using default values provided by the CacheItemPriority enumeration.

[Visual Basic] Overloads Public Sub Insert(String, Object)
[C#] public void Insert(string, object);
[C++] public: void Insert(String*, Object*);
[JScript] public function Insert(String, Object);

Inserts an object into the Cache that has file or key dependencies.

[Visual Basic] Overloads Public Sub Insert(String, Object, CacheDependency)
[C#] public void Insert(string, object, CacheDependency);
[C++] public: void Insert(String*, Object*, CacheDependency*);
[JScript] public function Insert(String, Object, CacheDependency);

Inserts an object into the Cache with dependencies and expiration policies.

[Visual Basic] Overloads Public Sub Insert(String, Object, CacheDependency, DateTime, TimeSpan)
[C#] public void Insert(string, object, CacheDependency, DateTime, TimeSpan);
[C++] public: void Insert(String*, Object*, CacheDependency*, DateTime, TimeSpan);
[JScript] public function Insert(String, Object, CacheDependency, DateTime, TimeSpan);

Inserts an object into the Cache object with dependencies, expiration and priority policies, and a delegate you can use to notify your application when the inserted item is removed from the Cache.

[Visual Basic] Overloads Public Sub Insert(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback)
[C#] public void Insert(string, object, CacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback);
[C++] public: void Insert(String*, Object*, CacheDependency*, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback*);
[JScript] public function Insert(String, Object, CacheDependency, DateTime, TimeSpan, CacheItemPriority, CacheItemRemovedCallback);

Example

[Visual Basic, C#, C++] The following example demonstrates how to assign an item high priority when you insert it into your application's Cache object.

[Visual Basic, C#, C++] Note   For more information about how to use this method with the CacheItemRemovedCallback delegate, see Notifying an Application When an Item Is Deleted from the Cache.
[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of Insert. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Cache.Insert("DSN", connectionString, Nothing, DateTime.Now.AddMinutes(2), TimeSpan.Zero, CacheItemPriority.High, onRemove)

[C#] 
Cache.Insert("DSN", connectionString, null, DateTime.Now.AddMinutes(2), TimeSpan.Zero, CacheItemPriority.High, onRemove);
   

[C++] 
Cache->Insert(S"DSN", connectionString, 0, DateTime::Now.AddMinutes(2), TimeSpan::Zero, CacheItemPriority::High, onRemove);
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Cache Class | Cache Members | System.Web.Caching Namespace

Show:
© 2014 Microsoft