-
Notifications
You must be signed in to change notification settings - Fork 1
/
MediaCacheInvalidator.cs
48 lines (36 loc) · 1.14 KB
/
MediaCacheInvalidator.cs
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
40
41
42
43
44
45
46
47
48
using Rhythm.Extensions.Events;
using Rhythm.Extensions.Interfaces;
using System.Collections.Generic;
namespace Rhythm.Extensions.Types {
/// <summary>
/// Invalidates an InstanceByKeyCache when media of particular ID's are changed.
/// </summary>
/// <typeparam name="T">The type of data being cached.</typeparam>
public class MediaCacheInvalidator<T> : ICacheByKeyInvalidator {
#region Properties
/// <summary>
/// The instance cache to invalidate.
/// </summary>
private InstanceByKeyCache<T, int> InstanceCache { get; set; }
#endregion
#region Constructors
/// <summary>
/// Full constructor.
/// </summary>
/// <param name="cache">The instance cache to invalidate.</param>
public MediaCacheInvalidator(InstanceByKeyCache<T, int> cache) {
this.InstanceCache = cache;
RhythmEventHandler.RegisterInvalidator(this);
}
#endregion
#region Methods
/// <summary>
/// Invalidates the cache for the specified ID's.
/// </summary>
/// <param name="ids">The ID's to invalidate the cache for.</param>
public void InvalidateForIds(IEnumerable<int> ids) {
this.InstanceCache.ClearKeys(ids);
}
#endregion
}
}