本文整理汇总了C#中Bucket.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Bucket.Remove方法的具体用法?C# Bucket.Remove怎么用?C# Bucket.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bucket
的用法示例。
在下文中一共展示了Bucket.Remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearBucket
private IEnumerator ClearBucket(Bucket bucket)
{
// Get all keys in the given bucket.
var getKeysRequest = bucket.GetKeys();
yield return getKeysRequest.WaitUntilDone();
if (getKeysRequest.hasFailed)
{
Debug.LogError("Unable to clear " + bucket + ". " + getKeysRequest.GetErrorString());
yield break;
}
// Remove each one of the keys. Issue the requests all at once.
var removeRequests = new List<RemoveRequest>();
foreach (var key in getKeysRequest.GetKeyEnumerable())
{
removeRequests.Add(bucket.Remove(key));
}
// Then wait for each request to finish.
foreach (var removeRequest in removeRequests)
{
yield return removeRequest.WaitUntilDone();
if (removeRequest.hasFailed)
Debug.LogError("Unable to remove '" + removeRequest.key + "' from " + removeRequest.bucket + ". " +
removeRequest.GetErrorString());
}
// Finally refresh the list.
StartCoroutine(RefreshList());
}
示例2: write
private void write(Bucket bucket) //bucket is locked already
{
var now = App.LocalizedTime;
var removed = new Lazy<List<Guid>>(false);
foreach (var pair in bucket)
{
var entry = pair.Value;
lock(entry)
{
//evict expired object and delete evicted or marked for deletion
if (
(
(entry.Status == ObjectStoreEntryStatus.Normal ||
entry.Status == ObjectStoreEntryStatus.ChekedIn //checked-in but not written yet
)
&&
entry.LastTime.AddMilliseconds( (entry.MsTimeout > 0) ? entry.MsTimeout : m_ObjectLifeSpanMS ) < now
) ||
(entry.Status == ObjectStoreEntryStatus.Deleted)
)
{
var wasWritten = entry.Status == ObjectStoreEntryStatus.Normal || entry.Status == ObjectStoreEntryStatus.Deleted;
entry.Status = ObjectStoreEntryStatus.Deleted;//needed for Normal objects that have just expired
removed.Value.Add(entry.Key);
if (wasWritten)
{ //delete form disk only if it was already written(normal)
try
{
m_Provider.Delete(entry);
}
catch (Exception error)
{
log(MessageType.CatastrophicError, "Provider error in .Delete(entry): " + error.Message, null);
}
}
try
{
if (entry.Value!=null && entry.Value is IDisposable)
((IDisposable)entry.Value).Dispose();
}
catch (Exception error)
{
log(MessageType.Error, "Exception from evicted object IDisposable.Dispose(): " + error.Message, null);
}
continue;
}
if (entry.Status == ObjectStoreEntryStatus.ChekedIn)
{
try
{
m_Provider.Write(entry);
}
catch (Exception error)
{
log(MessageType.CatastrophicError, "Provider error in .Write(entry): " + error.Message, null);
}
entry.Status = ObjectStoreEntryStatus.Normal;
}
}//lock entry
}//for
if (removed.IsValueCreated)
{
foreach(var key in removed.Value)
bucket.Remove(key);
log(MessageType.Info, string.Format("Removed {0} objects", removed.Value.Count), null);
}
bucket.LastAcquire = App.LocalizedTime;
}
示例3: Remove
private IEnumerator Remove(Bucket bucket, string key)
{
// Remove one entry from the database.
var removeRequest = bucket.Remove(key);
yield return removeRequest.WaitUntilDone();
if (removeRequest.hasFailed)
Debug.LogError("Unable to remove '" + removeRequest.key + "' from " + removeRequest.bucket + ". " +
removeRequest.GetErrorString());
// Refresh the list once the request has completed.
StartCoroutine(RefreshList());
}