Esempio n. 1
0
 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());
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void IncrementDiaryViews(long diaryId)
        {
            DiaryViewKey key = CacheContextKeyBuilder.BuildDiaryViewKey(diaryId);

            TripMeCacheContext.Context().SortedSetIncrement(key.sortedSetKey, key.memberKey, 1);
        }
Esempio n. 4
0
        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());
        }