wcf - Can i use System.Runtime.Caching.MemoryCache in cloud web role project? -
i use system.runtime.caching.memorycache
in web role project contains wcf service
.
can please let me know whether can use system.runtime.caching.memorycache
in cloud web
role project?
if yes please let me know memory , other constraints.
yes can.
you should add reference system.runtime.caching web role project, use code below (it doing nothing , not best practice, sure).
just tried asp.net mvc in cloud web role azure emulator , works.
regarding limits - there 2 cachememorylimit , physicalmemorylimit properties can use retrieve needed values. shows limit in bytes. not know if there limits beyond these in terms of in-memory cache in azure cloud services.
private static object _lock = new object(); private static memorycache _cache = new memorycache("thisismycache"); public static object getitem(string key) { lock (_lock) { var item = _cache.get(key); if (item == null) { item = initiaizeitem(key); _cache.set(key, item, new cacheitempolicy()); } return item; } } private static object initiaizeitem(string key) { return new { value = key }; }
Comments
Post a Comment