Is there any rule to give proper name for the cache key we use in ASP.Net.
string cacheKey = "aaaabbbbbsssssssss";
ObjectCache cache = MemoryCache.Default;
CacheItemPolicy cacheItemPolicy = new CacheItemPolicy();
cacheItemPolicy.AbsoluteExpiration = DateTime.Now.AddDays(15);
cache.Add(cacheKey, definitions, cacheItemPolicy);
Here the cacheKey = needs to be any string..I am concerned about the value of “cacheKey”
If you’re talking about
HttpContext.Current.Cache, then no. Generally speaking, it’s your application that uses this cache, so you have full control over what you call the keys.That said: if you’re concerned about collisions (e.g. between other assemblies that you’re using), consider using a namespace-qualified name — the typename of the class that owns the cache value might work. Alternatively, you might use a URI — they’re good for relatively unique names, since people are unlikely to use your domain name without meaning to. Of course, there’s always GUIDs.