public virtual void ItemRemoved(CacheItemMetadata metadata)
 {
     StorageMetadata.AddOrUpdate(metadata.Domain, metadata.Size, (d, l) => l - metadata.Size);
     lock (_lock)
     {
         GrandTotal -= metadata.Size;
     }
 }
 public virtual void ItemRemoved(CacheItemMetadata metadata)
 {
     StorageMetadata.AddOrUpdate(metadata.Domain, metadata.Size, (d, l) => l - metadata.Size);
     lock (_lock)
     {
         GrandTotal -= metadata.Size;
     }
 }
        public virtual void ItemAdded(CacheItemMetadata metadata)
        {
            StorageMetadata.AddOrUpdate(metadata.Domain, metadata.Size, (d, l) => l + metadata.Size);
            var total = StorageMetadata[metadata.Domain];
            lock (_lock)
            {
                GrandTotal += metadata.Size;
            }

            if(_needsGrandTotalHouseKeeping && GrandTotal>_settings.TotalQuota)
                DoHouseKeepingAsync();

            if (_needsPerDomainHouseKeeping && total > _settings.PerDomainQuota)
                DoDomainHouseKeepingAsync(metadata.Domain);
        }
        public virtual void ItemAdded(CacheItemMetadata metadata)
        {
            StorageMetadata.AddOrUpdate(metadata.Domain, metadata.Size, (d, l) => l + metadata.Size);
            var total = StorageMetadata[metadata.Domain];

            lock (_lock)
            {
                GrandTotal += metadata.Size;
            }

            if (_needsGrandTotalHouseKeeping && (GrandTotal > _settings.TotalQuota))
            {
                DoHouseKeepingAsync();
            }

            if (_needsPerDomainHouseKeeping && (total > _settings.PerDomainQuota))
            {
                DoDomainHouseKeepingAsync(metadata.Domain);
            }
        }