/// <summary> /// Read Through Cache /// </summary> /// <param name="id"></param> /// <returns></returns> private MarkerInfoResponse GetMarkerInfoResponse(int uid, string pointType = null) { try { var cacheKey = CacheKeys.GetMarkerInfo(uid); var reply = _memCache.Get <MarkerInfoResponse>(cacheKey); if (reply != null) { // return cached data reply.IsCached = true; return(reply); } MapPoint marker = _pointCollection.Get(pointType).SingleOrDefault(i => i.MarkerId == uid); reply = new MarkerInfoResponse { Id = uid.ToString() }; reply.BuildContent(marker); if (GmcConfiguration.Get.CacheServices) { _memCache.Set(cacheKey, reply, TimeSpan.FromMinutes(10)); // cache data } return(reply); } catch (Exception ex) { return(new MarkerInfoResponse { OperationResult = "0", ErrorMessage = string.Format("MapService says: Parsing error param: {0}", ex.Message) }); } }
/// <summary> /// Read Through Cache /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonMarkerInfoReply GetMarkerInfoHelper(string id) { if (string.IsNullOrWhiteSpace(id)) { return(new JsonMarkerInfoReply { Ok = "0", EMsg = "MapService says: params is invalid" }); } try { var uid = int.Parse(id); var cacheKey = CacheKeys.GetMarkerInfo(uid); var reply = _memCache.Get <JsonMarkerInfoReply>(cacheKey); if (reply != null) { // return cached data reply.Cache = true; return(reply); } P marker = _pointsDatabase.GetPoints().SingleOrDefault(i => i.I == uid); reply = new JsonMarkerInfoReply { Id = id }; reply.BuildContent(marker); if (GmcSettings.Get.CacheServices) { _memCache.Set(reply, cacheKey, TimeSpan.FromMinutes(10)); // cache data } return(reply); } catch (Exception ex) { return(new JsonMarkerInfoReply { Ok = "0", EMsg = string.Format("MapService says: Parsing error param: {0}", ex.Message) }); } }