public static void TestAssetLocalStorageLmdbPartitionedLRU_StoreAsset_Purge_Cycle()
        {
            Assert.DoesNotThrow(() => {
                for (var i = 0; i < 100; ++i)
                {
                    var assetId = Guid.NewGuid();

                    _localStorage.StoreAsset(new StratusAsset {
                        Id   = assetId,
                        Data = new byte[RandomUtil.NextUInt() % (DATABASE_MAX_SIZE_BYTES / 8 - 4096) + 4096],
                    });

                    Thread.Sleep(1000 / 8);

                    _localStorage.Purge(assetId);
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Purges the given asset from disk and memory.
        /// Never touches the remotes.
        /// </summary>
        /// <param name="assetId">Asset identifier.</param>
        /// <param name="resultCallback">Result callback.</param>
        public void PurgeAsset(Guid assetId, PurgeResultCallback resultCallback)
        {
            if (assetId == Guid.Empty)
            {
                throw new ArgumentException("Asset Id should not be empty.", nameof(assetId));
            }

            IChattelLocalStorage chattelStorage = _localStorage;

            var result = PurgeResult.NOT_FOUND_LOCALLY;

            try {
                chattelStorage.Purge(assetId);
                result = PurgeResult.DONE;
            }
            catch (AssetNotFoundException) {
                // Nothing to do here.
            }

            resultCallback(result);
        }
Esempio n. 3
0
 public static void TestAssetLocalStorageLmdbCtor2_Purge_EmpyId_ArgumentException()
 {
     Assert.Throws <ArgumentException>(() => _localStorage.Purge(Guid.Empty));
 }