velocity .net 下的分布式缓存产品

虽然我们有memcache这样的缓存服务器也可以通过.net来访问,但是一个真正.net 下的分布式缓存组件还是很有需求的,在这时微软推出了这个velocity,现在还只在ctp中。

http://www.cnblogs.com/024hi/archive/2008/08/29/1279409.html asp.net mvc 中使用velocity,这篇文章详细介绍了velocity的安装和使用
 
安装前先建立一个目录,用来网络上共享配置,这个目录要设成everyone帐号。
. start cluster – 为组中的每一台缓存服务器启动Velocity。每次开始时运行这个

 

· stop cluster – 与上一条正相反。

· create cache – 建立并命名一个新缓存。

· delete cache – 删除一个已存在的缓存。

· list host – 列出组中的所有缓存服务器

· list cache – 类出组中的所有缓存配置。

· show hoststats <cache server>:<cache port>– 列出指定缓存服务器上的统计信息。

. show cachestats <cachename>:缓存状态

 

需要注意的是,我设置了防火墙开放22233,22234端口,也给DsitributedCache.exe 和Administrator tool开放了访问,但是,我在控制台中start cluster会超时,同时在任务管理器中能看到进程运行了。我把防火墙关了就一切正常了。(vista系统)。

 

在.net 中访问velocity简直太容易了,和使用asp.net cache 没有太大差别,需要引用 CacheBaseLibrary.dll,ClientLibrary.dll,FabricCommon.dll。

 

static void Main(string[] args)
        {
            CacheFactory cf = new CacheFactory();
            Cache cache=cf.GetCache(”default”);//////default是一个默认的缓存名,可以建自己的名字
            cache.Put(”test_key”, DateTime.Now);
            var storevalue = cache.Get(”test_key”) ;
            Console.ReadLine();
        }
 
配置文件也很简单,app.config:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
    <configSections>
        <section name=”dcacheClient”
        type=”System.Configuration.IgnoreSectionHandler”
        allowLocation=”true” allowDefinition=”Everywhere”/>
    </configSections>
    <dcacheClient deployment=”simple” localCache=”false”>
        <hosts>
            <!–List of hosts –>
            <host name=”localhost”
               cachePort=”22233″
               cacheHostName=”DistributedCacheService” />
        </hosts>
    </dcacheClient>
</configuration>
posted @ 2009-12-14 18:11  蛤蟆  阅读(1093)  评论(0编辑  收藏  举报