当前位置: 首页>>代码示例>>C#>>正文


C# Bucket.Remove方法代码示例

本文整理汇总了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());
    }
开发者ID:judah4,项目名称:battle-of-mages,代码行数:30,代码来源:uGameDBAdminInterface.cs

示例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;
        }
开发者ID:sergey-msu,项目名称:nfx,代码行数:84,代码来源:ObjectStoreService.cs

示例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());
    }
开发者ID:judah4,项目名称:battle-of-mages,代码行数:12,代码来源:uGameDBAdminInterface.cs


注:本文中的Bucket.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。