コード例 #1
0
        public override Hashtable GetStore()
        {
            var cache = HttpRuntime.Cache;

            var locker = new DoubleLocker<Hashtable>(
                () => cache[BucketName] as Hashtable,
                () =>
                {
                    var bucket = new Hashtable();

                    cache.Add(BucketName,
                              bucket,
                              null,
                              Cache.NoAbsoluteExpiration,
                              expiration,
                              PRIORITY,
                              ItemRemovedCallback);

                    OnBucketCreation();

                    return bucket;
                });

            return locker.Create();
        }
コード例 #2
0
        public override Hashtable GetStore()
        {
            if (!RunningInWebContext)
                throw new InvalidOperationException(
                    "An ASP.Net session must be available when using Session storage. No ASP.Net session was found in the current context.");

            var locker = new DoubleLocker<Hashtable>(
                () => HttpContext.Current.Session[BucketName] as Hashtable,
                () =>
                {
                    var bucket = new Hashtable();
                    HttpContext.Current.Session[BucketName] = bucket;
                    OnBucketCreation();
                    return bucket;
                });

            return locker.Create();
        }