mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-18 19:51:45 +08:00
committed by
Sébastien Ros
parent
4584da9214
commit
7e859f2ccf
@@ -2,19 +2,27 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.OutputCache.Models;
|
||||
using Orchard.Utility.Extensions;
|
||||
using Orchard.Environment.Configuration;
|
||||
using System.Web.Caching;
|
||||
|
||||
namespace Orchard.OutputCache.Services {
|
||||
/// <summary>
|
||||
/// Tenant wide case insensitive reverse index for <see cref="CacheItem"/> tags.
|
||||
/// </summary>
|
||||
public class DefaultTagCache : ITagCache {
|
||||
|
||||
private readonly ConcurrentDictionary<string, HashSet<string>> _dictionary;
|
||||
|
||||
public DefaultTagCache() {
|
||||
_dictionary = new ConcurrentDictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
|
||||
public DefaultTagCache(IWorkContextAccessor workContextAccessor, ShellSettings shellSettings) {
|
||||
var key = shellSettings.Name + ":TagCache";
|
||||
var workContext = workContextAccessor.GetContext();
|
||||
|
||||
_dictionary = workContext.HttpContext.Cache.Get(key) as ConcurrentDictionary<string, HashSet<string>>;
|
||||
|
||||
if (_dictionary == null) {
|
||||
_dictionary = new ConcurrentDictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
|
||||
workContext.HttpContext.Cache.Add(key, _dictionary, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tag(string tag, params string[] keys) {
|
||||
@@ -26,7 +34,7 @@ namespace Orchard.OutputCache.Services {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<string> GetTaggedItems(string tag) {
|
||||
HashSet<string> set;
|
||||
if (_dictionary.TryGetValue(tag, out set)) {
|
||||
|
||||
Reference in New Issue
Block a user