本文整理汇总了C#中CacheEntry.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# CacheEntry.Clone方法的具体用法?C# CacheEntry.Clone怎么用?C# CacheEntry.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheEntry
的用法示例。
在下文中一共展示了CacheEntry.Clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
/// <summary>
/// Adds a pair of key and value to the cache. If the specified key already exists
/// in the cache; it is updated, otherwise a new item is added to the cache.
/// </summary>
/// <param name="key">key of the entry.</param>
/// <param name="cacheEntry">the cache entry.</param>
/// <returns>returns the result of operation.</returns>
public override CacheInsResultWithEntry Insert(object key, CacheEntry cacheEntry, bool notify, object lockId, LockAccessType access, OperationContext operationContext)
{
bool requiresReplication = false;
requiresReplication = _context.CacheImpl.RequiresReplication;
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Insert_1", "enter");
Sync.AcquireWriterLock(Timeout.Infinite);
try
{
CacheEntry clone = null;
if (requiresReplication)
{
if (cacheEntry.HasQueryInfo)
clone = cacheEntry.Clone() as CacheEntry;
else
clone = cacheEntry;
}
CacheInsResultWithEntry result = Internal.Insert(key, cacheEntry, notify, lockId, access, operationContext);
if (requiresReplication)
{
if (result.Result == CacheInsResult.Success || result.Result == CacheInsResult.SuccessNearEvicition || result.Result == CacheInsResult.SuccessOverwrite || result.Result == CacheInsResult.SuccessOverwriteNearEviction)
{
CacheEntry cloneWithoutvalue = clone.CloneWithoutValue() as CacheEntry;
if (result.Result == CacheInsResult.SuccessOverwrite &&
access == LockAccessType.DONT_RELEASE)
{
clone.CopyLock(result.Entry.LockId, result.Entry.LockDate, result.Entry.LockExpiration);
}
#if !CLIENT
_context.CacheImpl.EnqueueForReplication(key, (int)ClusterCacheBase.OpCodes.Insert, new object[] { key, cloneWithoutvalue, operationContext }, clone.Size, cacheEntry.UserData, cacheEntry.DataSize);
#endif
}
}
return result;
}
finally
{
Sync.ReleaseWriterLock();
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Insert_1", "exit");
}
}
示例2: InsertInternal
internal override CacheInsResult InsertInternal(object key, CacheEntry cacheEntry, bool isUserOperation, CacheEntry oldEntry, OperationContext operationContext, bool updateIndex)
{
int bucketId = GetBucketId(key as string);
OperationLogger opLogger = null;
//muds:
//fetch the operation logger...
if (_logMgr.IsOperationAllowed(bucketId) && LocalBuckets.Contains(bucketId))
{
long oldEntrysize = oldEntry == null ? 0 : oldEntry.DataSize;
if (_logMgr.IsLoggingEnbaled(bucketId, LogMode.LogBeforeActualOperation) && isUserOperation)
{
_logMgr.LogOperation(bucketId, key, cacheEntry, OperationType.Insert);
return oldEntry != null ? CacheInsResult.SuccessOverwrite : CacheInsResult.Success;
}
CacheEntry clone = (CacheEntry)cacheEntry.Clone();
CacheInsResult result = base.InsertInternal(key, cacheEntry, isUserOperation, oldEntry, operationContext, updateIndex);
switch (result)
{
case CacheInsResult.SuccessNearEvicition:
case CacheInsResult.Success:
if (isUserOperation) _logMgr.LogOperation(bucketId, key, clone, OperationType.Insert);
IncrementBucketStats(key as string, bucketId, cacheEntry.DataSize);
break;
case CacheInsResult.SuccessOverwriteNearEviction:
case CacheInsResult.SuccessOverwrite:
if (isUserOperation) _logMgr.LogOperation(bucketId, key, clone, OperationType.Insert);
DecrementBucketStats(key as string, bucketId, oldEntrysize);
IncrementBucketStats(key as string, bucketId, cacheEntry.DataSize);
break;
}
return result;
}
throw new StateTransferException("I am no more the owner of this bucket");
}
示例3: Add
/// <summary>
/// Adds a pair of key and value to the cache. Throws an exception or reports error
/// if the specified key already exists in the cache.
/// </summary>
/// <param name="key">key of the entry.</param>
/// <param name="cacheEntry">the cache entry.</param>
/// <param name="notify"></param>
/// <param name="operationContext"></param>
/// <returns>returns the result of operation.</returns>
public override CacheAddResult Add(object key, CacheEntry cacheEntry, bool notify, OperationContext operationContext)
{
bool requiresReplication = _context.CacheImpl.RequiresReplication;
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Add_1", "enter");
Sync.AcquireWriterLock(Timeout.Infinite);
try
{
CacheEntry clone = null;
if ((requiresReplication))
{
if (cacheEntry.HasQueryInfo)
clone = cacheEntry.Clone() as CacheEntry;
else
clone = cacheEntry;
}
CacheAddResult result = Internal.Add(key, cacheEntry, notify, operationContext);
if (requiresReplication)
{
if (result == CacheAddResult.Success || result == CacheAddResult.SuccessNearEviction)
{
if (requiresReplication)
{
CacheEntry cloneWithoutvalue = clone.CloneWithoutValue() as CacheEntry;
Array userPayLoad = cacheEntry.UserData;
long payLoadSize = cacheEntry.DataSize;
#if !CLIENT
_context.CacheImpl.EnqueueForReplication(key, (int)ClusterCacheBase.OpCodes.Add, new object[] { key, cloneWithoutvalue, operationContext }, clone.Size, userPayLoad, payLoadSize);
#endif
}
}
}
return result;
}
finally
{
Sync.ReleaseWriterLock();
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Add_1", "exit");
}
}
示例4: AddInternal
internal override CacheAddResult AddInternal(object key, CacheEntry cacheEntry, bool isUserOperation, OperationContext operationContext)
{
int bucketId = GetBucketId(key as string);
if (_logMgr.IsOperationAllowed(bucketId) && LocalBuckets.Contains(bucketId))
{
if (_logMgr.IsLoggingEnbaled(bucketId, LogMode.LogBeforeActualOperation) && isUserOperation)
{
_logMgr.LogOperation(bucketId, key, cacheEntry, OperationType.Add);
return CacheAddResult.Success;
}
CacheEntry clone = (CacheEntry)cacheEntry.Clone();
CacheAddResult result = base.AddInternal(key, cacheEntry, isUserOperation, operationContext);
if (result == CacheAddResult.Success || result == CacheAddResult.SuccessNearEviction)
{
IncrementBucketStats(key as string, bucketId, clone.DataSize);
if (isUserOperation) _logMgr.LogOperation(bucketId, key, clone, OperationType.Add);
}
return result;
}
throw new StateTransferException("I am no more the owner of this bucket");
}