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