Ejemplo n.º 1
0
        public async Task <ICollection <NoteModels> > GetTrashNotes(long Id)
        {
            var    cacheKey = "ReminderNotes:" + Id.ToString();
            string serializedNotes;
            ICollection <NoteModels> Notes;

            try
            {
                var redisNoteCollection = await distributedCache.GetAsync(cacheKey);

                if (redisNoteCollection != null)
                {
                    serializedNotes = Encoding.UTF8.GetString(redisNoteCollection);
                    Notes           = JsonConvert.DeserializeObject <List <NoteModels> >(serializedNotes);
                }
                else
                {
                    Notes = notesRL.GetNotes(Id, true, false);
                    await redis.AddRedisCache(cacheKey, Notes);
                }
                return(Notes);
            }

            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task <ICollection <ResponseNoteModel> > GetActiveNotes(long UserID)
        {
            var    cacheKey = "ActiveNotes:" + UserID.ToString();
            string serializedNotes;
            ICollection <ResponseNoteModel> Notes;

            try
            {
                var redisNoteCollection = await distributedCache.GetAsync(cacheKey);

                if (redisNoteCollection != null)
                {
                    serializedNotes = Encoding.UTF8.GetString(redisNoteCollection);
                    Notes           = JsonConvert.DeserializeObject <List <ResponseNoteModel> >(serializedNotes);
                }
                else
                {
                    Notes = notesRL.GetNotes(UserID);
                    await redis.AddRedisCache(cacheKey, Notes);
                }
                return(Notes);
            }
            catch (Exception)
            {
                throw;
            }
        }