HttpRequestCachePolicy Oluşturucular
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
HttpRequestCachePolicy sınıfının yeni bir örneğini başlatır.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| HttpRequestCachePolicy() |
HttpRequestCachePolicy sınıfının yeni bir örneğini başlatır. |
| HttpRequestCachePolicy(DateTime) |
Belirtilen önbellek eşitleme tarihini kullanarak sınıfın HttpRequestCachePolicy yeni bir örneğini başlatır. |
| HttpRequestCachePolicy(HttpRequestCacheLevel) |
Belirtilen önbellek ilkesini kullanarak sınıfın HttpRequestCachePolicy yeni bir örneğini başlatır. |
| HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan) |
Belirtilen yaş denetimi ve saat değerlerini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır. |
| HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan) |
Belirtilen en büyük yaş, yaş denetimi değeri ve saat değerini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır. |
| HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime) |
Belirtilen en büyük yaş, yaş denetimi değeri, saat değeri ve önbellek eşitleme tarihini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır. |
HttpRequestCachePolicy()
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
HttpRequestCachePolicy sınıfının yeni bir örneğini başlatır.
public:
HttpRequestCachePolicy();
public HttpRequestCachePolicy();
Public Sub New ()
Örnekler
Aşağıdaki kod örneği, bu oluşturucuyu kullanarak önbellek ilkesini ayarlamayı gösterir.
public static WebResponse GetResponseUsingCacheDefault(Uri uri)
{
// Set the default cache policy level for the "http:" scheme.
RequestCachePolicy policy = new RequestCachePolicy();
// Create the request.
WebRequest request = WebRequest.Create(uri);
request.CachePolicy = policy;
WebResponse response = request.GetResponse();
Console.WriteLine("Policy level is {0}.", policy.Level.ToString());
Console.WriteLine("Is the response from the cache? {0}", response.IsFromCache);
return response;
}
Açıklamalar
Bu oluşturucu özelliğini olarak DefaultbaşlatırLevel.
Şunlara uygulanır
HttpRequestCachePolicy(DateTime)
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
Belirtilen önbellek eşitleme tarihini kullanarak sınıfın HttpRequestCachePolicy yeni bir örneğini başlatır.
public:
HttpRequestCachePolicy(DateTime cacheSyncDate);
public HttpRequestCachePolicy(DateTime cacheSyncDate);
new System.Net.Cache.HttpRequestCachePolicy : DateTime -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheSyncDate As DateTime)
Parametreler
- cacheSyncDate
- DateTime
DateTime Önbellekte depolanan kaynakların yeniden karşılanması gereken zamanı belirten bir nesne.
Örnekler
Aşağıdaki kod örneği, önbellek eşitleme tarihini temel alan bir önbellek ilkesi oluşturmayı gösterir.
public static HttpRequestCachePolicy CreateLastSyncPolicy(DateTime when)
{
HttpRequestCachePolicy policy =
new HttpRequestCachePolicy(when);
Console.WriteLine("When: {0}", when);
Console.WriteLine(policy.CacheSyncDate.ToString());
return policy;
}
Açıklamalar
Önbellek eşitleme tarihi, önbelleğe alınan içeriğin yeniden doğrulanması gerektiğinde mutlak bir tarih belirtmenize olanak tanır. Önbellek girdisi en son önbellek eşitleme tarihinden önce yeniden karşılandıysa, sunucuyla yeniden doğrulama gerçekleşir. Önbellek girdisi önbellek eşitleme tarihinden sonra yeniden doğrulandıysa ve önbelleğe alınan girişi geçersiz hale getiren bir sunucu yeniden doğrulama gereksinimi yoksa, önbellekten gelen girdi kullanılır. Önbellek eşitleme tarihi gelecekteki bir tarihe ayarlanırsa, önbellek eşitleme tarihi geçene kadar giriş her istendiği zaman yeniden doğrulanır.
Bu oluşturucu özelliğini olarak DefaultbaşlatırLevel.
CacheSyncDate özelliği cacheSyncDate olarak başlatılır.
Şunlara uygulanır
HttpRequestCachePolicy(HttpRequestCacheLevel)
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
Belirtilen önbellek ilkesini kullanarak sınıfın HttpRequestCachePolicy yeni bir örneğini başlatır.
public:
HttpRequestCachePolicy(System::Net::Cache::HttpRequestCacheLevel level);
public HttpRequestCachePolicy(System.Net.Cache.HttpRequestCacheLevel level);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpRequestCacheLevel -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (level As HttpRequestCacheLevel)
Parametreler
- level
- HttpRequestCacheLevel
Bir HttpRequestCacheLevel değer.
Örnekler
Aşağıdaki kod örneği, önbellekte bulunan kaynakların önbellekten kullanılmasına izin veren bir önbellek ilkesi oluşturmayı gösterir.
public static HttpRequestCachePolicy CreateCacheIfAvailablePolicy()
{
HttpRequestCachePolicy policy =
new HttpRequestCachePolicy(HttpRequestCacheLevel.CacheIfAvailable);
Console.WriteLine(policy.ToString());
return policy;
}
Açıklamalar
Bu oluşturucu özelliğini olarak levelbaşlatırLevel.
HttpRequestCacheLevel Değer, önbelleğe almanın etkinleştirilip etkinleştirilmediğini ve önbelleğin ne zaman kullanılabileceğini denetler. Ek bilgi için belgelere HttpRequestCacheLevel bakın.
Şunlara uygulanır
HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan)
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
Belirtilen yaş denetimi ve saat değerlerini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır.
public:
HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan ageOrFreshOrStale);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, ageOrFreshOrStale As TimeSpan)
Parametreler
- cacheAgeControl
- HttpCacheAgeControl
Aşağıdaki HttpCacheAgeControl numaralandırma değerlerinden biri: MaxAge, MaxStaleveya MinFresh.
Özel durumlar
parametresi için cacheAgeControl belirtilen değer bu oluşturucuyla kullanılamaz.
Örnekler
Aşağıdaki kod örneği, en düşük güncelliği temel alan bir önbellek ilkesi oluşturmayı gösterir.
public static HttpRequestCachePolicy CreateMinFreshPolicy(TimeSpan span)
{
HttpRequestCachePolicy policy =
new HttpRequestCachePolicy(HttpCacheAgeControl.MinFresh, span);
Console.WriteLine("Minimum freshness {0}", policy.MinFresh.ToString());
return policy;
}
Açıklamalar
cacheAgeControl değeri parametre değerinin ageOrFreshOrStale anlamını tanımlar ve ilişkili özelliği ayarlamak için kullanılır. Örneğin, belirttiğinizde MaxStaleMaxStale özelliği parametresinin ageOrFreshOrStale değerine ayarlanır.
Bu oluşturucu özelliğini olarak DefaultbaşlatırLevel.
Şunlara uygulanır
HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan)
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
Belirtilen en büyük yaş, yaş denetimi değeri ve saat değerini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır.
public:
HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan * TimeSpan -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, maxAge As TimeSpan, freshOrStale As TimeSpan)
Parametreler
- cacheAgeControl
- HttpCacheAgeControl
Bir HttpCacheAgeControl değer.
Özel durumlar
cacheAgeControl parametresi için belirtilen değer geçerli değil.
Örnekler
Aşağıdaki kod örneği, en düşük güncellik ve maksimum yaşa göre önbellek ilkesi oluşturmayı gösterir.
public static HttpRequestCachePolicy CreateFreshAndAgePolicy(TimeSpan freshMinimum, TimeSpan ageMaximum)
{
HttpRequestCachePolicy policy =
new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, ageMaximum, freshMinimum);
Console.WriteLine(policy.ToString());
return policy;
}
Açıklamalar
cacheAgeControl değeri, parametre değerinin freshOrStale anlamını yorumlamak ve ilişkili özelliği ayarlamak için kullanılır. Örneğin, belirttiğinizde MaxStaleMaxStale özelliği parametresinin freshOrStale değerine ayarlanır. belirttiğinizdeMaxAgeAndMaxStaleMaxAge, özelliği parametresinin maxAge değeri kullanılarak ayarlanır ve MaxStale özellik parametresinin freshOrStale değeri kullanılarak ayarlanır.
veya MaxAgeAndMinFreshbelirtmediğiniz MaxAgeAndMaxStale sürece özelliğinin MaxAge ayarlanmadığını unutmayın.
Bu oluşturucu özelliğini olarak DefaultbaşlatırLevel.
Şunlara uygulanır
HttpRequestCachePolicy(HttpCacheAgeControl, TimeSpan, TimeSpan, DateTime)
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
- Kaynak:
- HttpRequestCachePolicy.cs
Belirtilen en büyük yaş, yaş denetimi değeri, saat değeri ve önbellek eşitleme tarihini kullanarak sınıfın yeni bir örneğini HttpRequestCachePolicy başlatır.
public:
HttpRequestCachePolicy(System::Net::Cache::HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate);
public HttpRequestCachePolicy(System.Net.Cache.HttpCacheAgeControl cacheAgeControl, TimeSpan maxAge, TimeSpan freshOrStale, DateTime cacheSyncDate);
new System.Net.Cache.HttpRequestCachePolicy : System.Net.Cache.HttpCacheAgeControl * TimeSpan * TimeSpan * DateTime -> System.Net.Cache.HttpRequestCachePolicy
Public Sub New (cacheAgeControl As HttpCacheAgeControl, maxAge As TimeSpan, freshOrStale As TimeSpan, cacheSyncDate As DateTime)
Parametreler
- cacheAgeControl
- HttpCacheAgeControl
Bir HttpCacheAgeControl değer.
- cacheSyncDate
- DateTime
DateTime Önbellekte depolanan kaynakların yeniden karşılanması gereken zamanı belirten bir nesne.
Örnekler
Aşağıdaki kod örneği, en düşük güncellik, en yüksek yaş ve önbellek eşitleme tarihine göre önbellek ilkesi oluşturmayı gösterir.
public static HttpRequestCachePolicy CreateFreshAndAgePolicy2(TimeSpan freshMinimum, TimeSpan ageMaximum, DateTime when)
{
HttpRequestCachePolicy policy =
new HttpRequestCachePolicy(HttpCacheAgeControl.MaxAgeAndMinFresh, ageMaximum, freshMinimum, when);
Console.WriteLine(policy.ToString());
return policy;
// For the following invocation:
// CreateFreshAndAgePolicy(new TimeSpan(5,0,0), new TimeSpan(10,0,0),);
// the output is:
// Level:Automatic
// AgeControl:MinFreshAndMaxAge
// MinFresh:18000
// MaxAge:36000
}
Açıklamalar
cacheAgeControl değeri, parametre değerinin freshOrStale anlamını yorumlamak ve ilişkili özelliği ayarlamak için kullanılır. Örneğin, belirttiğinizde MaxStaleMaxStale özelliği parametresinin freshOrStale değerine ayarlanır. belirttiğinizdeMaxAgeAndMaxStaleMaxAge, özelliği parametresinin maxAge değeri kullanılarak ayarlanır ve MaxStale özellik parametresinin freshOrStale değeri kullanılarak ayarlanır.
veya MaxAgeAndMinFreshbelirtmediğiniz MaxAgeAndMaxStale sürece özelliğinin MaxAge ayarlanmadığını unutmayın.
Bu oluşturucu, için özelliğini cacheSyncDatebaşlatır CacheSyncDate ve özelliğini olarak DefaultbaşlatırLevel.