132
|
1 private import tango.core.Thread;
|
|
2
|
|
3 private import tango.util.log.Configurator;
|
|
4
|
|
5 private import tango.net.cluster.tina.Cluster;
|
|
6
|
|
7 private import tango.net.cluster.QueuedCache,
|
|
8 tango.net.cluster.CacheInvalidatee,
|
|
9 tango.net.cluster.CacheInvalidator;
|
|
10
|
|
11 /*******************************************************************************
|
|
12
|
|
13 Demonstrates how to invalidate cache entries across a cluster
|
|
14 via a channel
|
|
15
|
|
16 *******************************************************************************/
|
|
17
|
|
18 void main()
|
|
19 {
|
|
20 // access the cluster
|
|
21 auto cluster = (new Cluster).join;
|
|
22
|
|
23 // wrap a cache instance with a network listener
|
|
24 auto dst = new CacheInvalidatee (cluster, "my.cache.channel", new QueuedCache!(char[], IMessage)(101));
|
|
25
|
|
26 // connect an invalidator to that cache channel
|
|
27 auto src = new CacheInvalidator (cluster, "my.cache.channel");
|
|
28
|
|
29 // stuff something in the local cache
|
|
30 dst.cache.put ("key", dst.EmptyMessage);
|
|
31
|
|
32 // get it removed via a network broadcast
|
|
33 src.log.info ("invalidating 'key' across the cluster");
|
|
34 src.invalidate ("key");
|
|
35
|
|
36 // wait for it to arrive ...
|
|
37 Thread.sleep (1);
|
|
38 }
|