Beispiel #1
0
 public static IObservable <CacheIndex> AddAndSaveToIndex(IBlobCache cache, string indexKey, CacheItem item,
                                                          DateTimeOffset?absoluteExpiration = null)
 {
     return(cache.GetOrCreateObject(indexKey, () => Create(indexKey))
            .Do(index =>
     {
         var k = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", index.IndexKey, item.Key);
         if (!index.Keys.Contains(k))
         {
             index.Keys.Add(k);
         }
         index.UpdatedAt = DateTimeOffset.UtcNow;
     })
            .SelectMany(index => cache.InsertObject(index.IndexKey, index, absoluteExpiration)
                        .Select(x => index)));
 }
Beispiel #2
0
        public IObservable <CacheIndex> AddAndSave(IBlobCache cache, string indexKey, CacheItem item,
                                                   DateTimeOffset?absoluteExpiration = null)
        {
            var k = string.Format(CultureInfo.InvariantCulture, "{0}|{1}", IndexKey, item.Key);

            if (!Keys.Contains(k))
            {
                Keys.Add(k);
            }
            UpdatedAt = DateTimeOffset.UtcNow;
            return(cache.InsertObject(IndexKey, this, absoluteExpiration)
                   .Select(x => this));
        }