我有這樣的代碼:lambda表達式功能
int pictureId=10;
string cacheKey = string.Format(ModelCacheEventConsumer.PICTURE_URL_MODEL_KEY, pictureId);
return _cacheManager.Get(cacheKey,() =>
{
var url = _pictureService.GetPictureUrl(pictureId, showDefaultPicture: false);
//little hack here. nulls aren't cacheable so set it to ""
if (url == null)
url = "";
return url;
});
究竟這部分代碼的意思是:」
() =>
{"
var url =...."
這是否意味着函數返回地址,是爲每一行的執行?緩存什麼,然後返回一個類型 - ?列表此語法的文檔
URL
_cacheManager是什麼類型? –
_cacheManager實現ICacheManager IDisposable接口,該接口的方法定義如下: T獲取(string key); –
Simon