Is there a good way to keep keys from conflicting when using the Microsoft CacheManager? What’s to stop someone from writing another class that uses the same key I do, not realizing it’s already been used? Does each web page need to use a separate cachemanager?
This would make it hard to share. I wonder the same thing about using the session. There seems to be no good way to manage keys and keep them unique.
I’ve seen other caching solutions that use the concept of a namespace. This would make sense if I could use the web page name as the namespace to keep things unique then some global namespace for things I want to share. The same probably applies to the session like I mentioned.
Even this example from the enterpriselibrary docs would make you think there is no great way to store more than one type of object for a given employee id.
cache.Add(employeeId.ToString(), photoData,
CacheItemPriority.High, null,
new ICacheItemExpiration[] { expiry });
You would almost need to store one master object that has everything you need, which I don’t want to do. Or you end up with bunch of nested dictionaries. Any ideas on how to best approach this issue?
Just make up a naming scheme, example:
“Path/To/File.Component.Object.Object2.Property”
That should be unique. Then build yourself some utility methods, that way you don’t have to manually copy-paste strings.