-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathCustomerServices.cs
More file actions
33 lines (29 loc) · 940 Bytes
/
CustomerServices.cs
File metadata and controls
33 lines (29 loc) · 940 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
using PostSharp.Patterns.Caching;
using System;
using System.Threading;
namespace PostSharp.Samples.Caching
{
[CacheConfiguration(AbsoluteExpiration = 10)]
internal class CustomerServices
{
[Cache]
public static Customer GetCustomer(int id)
{
Console.WriteLine($">> Retrieving the customer {id} from database...");
Thread.Sleep(1000);
return new Customer { Id = id, Name = "Rubber Debugging Duck" };
}
[InvalidateCache(nameof(GetCustomer))]
public static void UpdateCustomer(int id, string newName)
{
Console.WriteLine($">> Updating the customer {id} in database...");
Thread.Sleep(1000);
}
public static void DeleteCustomer(int id, string newName)
{
Console.WriteLine($">> Deleting the customer {id} from database...");
Thread.Sleep(1000);
CachingServices.Invalidation.Invalidate(GetCustomer, id);
}
}
}