. NET Framework Cache traversal

Source: Internet
Author: User

Background:

The company's old framework of login information with the memorycache saved, in order to achieve single-user login (that is, an account can not be logged in), you need to log in before the login information to do the traversal.

The general idea is as follows:

This method can be used to clear all caches.

1, Httpruntime.cache

System.Collections.IDictionaryEnumerator cacheenum = HttpRuntime.Cache.GetEnumerator ();
while (Cacheenum.movenext ()) {//cacheenum.key.tostring () is the cache name, Cacheenum.value is the cached value}

2, System.Runtime.Caching.ObjectCache
ObjectCache cache = Memorycache.default
ienumerable<keyvaluepair<string, object>> items = cache. AsEnumerable ();
foreach (keyvaluepair<string, object> item in items) {//item. Key is the cache name, item. Value is cached values}

This cache is. NET4.0 added.

Swim's supplementary note the principle of single-user login:

Single-user login, to have logged on user information to do the traversal, found the same login account, it is removed from the cache, and then do login

(distributed cache of the next replenishment!) )

2015-02-05

Wujf

Have the pursuit, only the power!

. NET Framework Cache traversal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.