using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Umbraco.Core.Cache
{
///
/// A cache provider that caches items in the HttpContext.Items
///
internal class HttpRequestCacheProvider : DictionaryCacheProviderBase
{
private readonly Func _context;
public HttpRequestCacheProvider(HttpContext context)
{
// create wrapper only once!
var wrapper = new HttpContextWrapper(context);
_context = () => wrapper;
}
public HttpRequestCacheProvider(Func context)
{
_context = context;
}
protected override IEnumerable GetDictionaryEntries()
{
const string prefix = CacheItemPrefix + "-";
return _context().Items.Cast()
.Where(x => x.Key is string && ((string)x.Key).StartsWith(prefix));
}
protected override void RemoveEntry(string key)
{
_context().Items.Remove(key);
}
protected override object GetEntry(string key)
{
return _context().Items[key];
}
#region Get
public override object GetCacheItem(string cacheKey, Func