本文整理汇总了C#中Request.GetCacheKey方法的典型用法代码示例。如果您正苦于以下问题:C# Request.GetCacheKey方法的具体用法?C# Request.GetCacheKey怎么用?C# Request.GetCacheKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.GetCacheKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public Request Add(Request request)
{
request.SetRequestQueue(this);
//��ӵ���ǰ�����б���
lock (mCurrentRequests)
{
mCurrentRequests.Add(request);
}
request.Sequence = GetSequenceNumber();
request.AddMarker("add-to-queue");
//���������Ҫ������ֱ�Ӽ��뵽�������������
if (!request.ShouldCache())
{
mNetworkQueue.Enqueue(request);
return request;
}
/*
* �Ƚ�������뵽������������У����ҽ�������ظ�����
* ��ӵ�mWaitingRequests�У�Ŀ���ǵ���һ��������ɺ�
* �����ظ�������ֱ����ӵ�������������У������ظ���
* �����������
*/
lock (mWaitingRequests)
{
String cacheKey = request.GetCacheKey();
if (mWaitingRequests.ContainsKey(cacheKey))
{
Queue<Request> stagedRequests = null;
mWaitingRequests.TryGetValue(cacheKey, out stagedRequests);
if (stagedRequests == null)
{
stagedRequests = new Queue<Request>();
}
stagedRequests.Enqueue(request);
if (VolleyLog.DEBUG)
{
VolleyLog.V("Request for cacheKey={0} is in flight,putting on hold.", cacheKey);
}
}
else
{
mWaitingRequests.Add(cacheKey, null);
mCacheQueue.Enqueue(request);
}
return request;
}
}
示例2: Finish
public void Finish(Request request)
{
lock (mCurrentRequests)
{
mCurrentRequests.Remove(request);
}
lock (mFinishedListeners)
{
foreach (IRequestFinishedListener listener in mFinishedListeners)
{
listener.OnRequestFinished(request);
}
}
if (request.ShouldCache())
{
/*
* �ڸ�������ɲ�������������ظ���
* ����ֱ�Ӽ��뵽�������������
*/
lock (mWaitingRequests)
{
String cacheKey = request.GetCacheKey();
Queue<Request> waitingRequets = null;
mWaitingRequests.TryGetValue(cacheKey, out waitingRequets);
mWaitingRequests.Remove(cacheKey);
if (waitingRequets != null)
{
if (VolleyLog.DEBUG)
{
VolleyLog.V("Releasing {0} waiting requests for cacheKey={1}", waitingRequets.Count, cacheKey);
}
foreach (Request addrequest in waitingRequets)
{
mCacheQueue.Enqueue(addrequest);
}
}
}
}
}