-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathUrlCache.cs
More file actions
39 lines (31 loc) · 988 Bytes
/
Copy pathUrlCache.cs
File metadata and controls
39 lines (31 loc) · 988 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sitecore.Caching;
using Sitecore.Configuration;
namespace NTTData.SitecoreCDN.Caching
{
/// <summary>
/// This cache keeps mappings of original urls to dehydrated cdn urls
/// /path/to/file.ext?a=1&b=2 => http://cdnhostname/path/to/file!cf!a=1!b=2.ext
/// </summary>
public class UrlCache: CustomCache
{
private TimeSpan _cacheTime;
public UrlCache(string name, long maxSize)
: base(name, maxSize)
{
//this.InnerCache.Scavengable = true;
_cacheTime = Settings.GetTimeSpanSetting("SitecoreCDN.UrlVersionCacheTime", "00:05:00");
}
public string GetUrl(string path)
{
return this.GetString(path);
}
public void SetUrl(string path, string url)
{
this.SetString(path, url, DateTime.UtcNow.Add(_cacheTime));
}
}
}