view tango/example/cluster/invalidate.d @ 270:d9d5d59873d8 trunk

[svn r291] Fixed a bunch of the old Phobos tests to work with Tango. Branch statements now emit a new block after it. Fixed the _adSort runtime function had a bad signature. Added a missing dot prefix on compiler generated string tables for string switch. Fixed, PTRSIZE seems like it was wrong on 64bit, now it definitely gets set properly.
author lindquist
date Mon, 16 Jun 2008 16:01:19 +0200
parents 1700239cab2e
children
line wrap: on
line source

private import  tango.core.Thread;

private import  tango.util.log.Configurator;

private import  tango.net.cluster.tina.Cluster;

private import  tango.net.cluster.QueuedCache,
                tango.net.cluster.CacheInvalidatee,
                tango.net.cluster.CacheInvalidator;

/*******************************************************************************

        Demonstrates how to invalidate cache entries across a cluster
        via a channel

*******************************************************************************/

void main()
{
        // access the cluster
        auto cluster = (new Cluster).join;

        // wrap a cache instance with a network listener
        auto dst = new CacheInvalidatee (cluster, "my.cache.channel", new QueuedCache!(char[], IMessage)(101));

        // connect an invalidator to that cache channel
        auto src = new CacheInvalidator (cluster, "my.cache.channel");

        // stuff something in the local cache
        dst.cache.put ("key", dst.EmptyMessage);

        // get it removed via a network broadcast
        src.log.info ("invalidating 'key' across the cluster");
        src.invalidate ("key");

        // wait for it to arrive ...
        Thread.sleep (1);
}