Esempio n. 1
0
 public Stream Set([NotNull] string key, object state, [NotNull] Action<ICacheContext> create)
 {
     var data = _memCache.Set<byte[]>(key, state, context =>
     {
         var subContext = new LocalContextWrapper(context);
         create(subContext);
         return subContext.GetBytes();
     });
     return new MemoryStream(data, writable: false);
 }
Esempio n. 2
0
        public async Task <Stream> SetAsync([NotNull] string key, object state, [NotNull] Func <ICacheContext, Task> create)
        {
            var data = await _memCache.SetAsync <byte[]>(key, link : null, state : state, create : async context =>
            {
                var subContext = new LocalContextWrapper(context);
                await create(subContext);
                return(subContext.GetBytes());
            });

            return(new MemoryStream(data, writable: false));
        }
Esempio n. 3
0
        public Stream Set([NotNull] string key, object state, [NotNull] Action <ICacheContext> create)
        {
            var data = _memCache.Set <byte[]>(key, state, context =>
            {
                var subContext = new LocalContextWrapper(context);
                create(subContext);
                return(subContext.GetBytes());
            });

            return(new MemoryStream(data, writable: false));
        }