public List <long> GetMostViewedDiariesId(long limitCount) { return(TripMeCacheContext.Context().SortedSetRangeByScore(CacheContextKeyBuilder.DiariesViewCountSortedSetKey, order: Order.Descending, take: limitCount) .Select(x => { string value = x.ToString(); return long.Parse(value); }).ToList()); }
public long GetDiaryViewsCount(long diaryId) { DiaryViewKey key = CacheContextKeyBuilder.BuildDiaryViewKey(diaryId); double? viewsCount = TripMeCacheContext.Context().SortedSetScore(key.sortedSetKey, key.memberKey); if (!viewsCount.HasValue) { return(0); } return((long)viewsCount.Value); }
public void IncrementDiaryViews(long diaryId) { DiaryViewKey key = CacheContextKeyBuilder.BuildDiaryViewKey(diaryId); TripMeCacheContext.Context().SortedSetIncrement(key.sortedSetKey, key.memberKey, 1); }
public List <Tuple <long, long> > GetDiaryViewsCount(string diaryMatchPattern) { IEnumerable <SortedSetEntry> result = TripMeCacheContext.Context().SortedSetScan(CacheContextKeyBuilder.DiariesViewCountSortedSetKey, diaryMatchPattern, 20); return(result.Select(x => new Tuple <long, long>(long.Parse(x.Element), (long)x.Score)).ToList()); }