拜年:indeXus.Net Shared Cache - 高性能,分布式缓存方案
2008-02-06 17:53
615 查看
昨天在codeplex.com上闲逛,偶遇到个好东西,提来给大家拜年。
-----------------------------------------------------------------------------------------
一、简介
出处:http://wuchang.cnblogs.com
indeXus.Net SharedCache是高性能的、分布式的内存对象系统,用于在动态WEB或Win应用程序中减少数据库的负责,提高访问速度。
SharedCache 全部的代码都是用c#写的,100% DotNet原生态。
先来看一下SharedCache 的几种方式:
1.Distributed Caching - partitioned
2.Replicated Caching
3.Single Instance Caching
二、小试牛刀
1.服务端
全部源码可以在SharedCache项目网站(http://www.codeplex.com/SharedCache)下载。
方案中中有7个项目
可以直接在vs2008 中打开编译。
但压缩包中缺少ICSharpCode.SharpZipLib.dll,编译前䉣准备好这个。
编译成功后MergeSystem.Indexus.WinService\bin\Debug目录的文件
job_install.bat / job_uninstall.bat 安装/卸载windows服务
job_startService.bat / job_stopService.bat 开启/停止服务
job_Console.bat 在控制台中加载服务。
如果不想安装到Windows服务中,直接用Job_Console.bat启动即可,默认监听端口是48888(在MergeSystem.Indexus.WinService.vshost.exe.config中配置),
2.测试程序
新建一个控制台程序,添加MergeSystem.Indexus.WinServiceCommon的引用。测试代码如下:
using System;
using MergeSystem.Indexus.WinServiceCommon.Provider.Cache;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
User[] data = new[] { new User{ Name="user1",Age=20},
new User{ Name="user2",Age=1},
new User{ Name="user3",Age=22}
};
foreach (var item in data)
{
IndexusDistributionCache.SharedCache.Add(item.Name, item);
}
Console.WriteLine("count={0}", IndexusDistributionCache.SharedCache.Count);
User user = IndexusDistributionCache.SharedCache.Get<User>("user2");
Console.WriteLine("name={0},age={1}", user.Name, user.Age);
Console.WriteLine("press any key to exit.");
Console.ReadKey();
}
}
[Serializable]
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
}
App.config中配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="indexusNetSharedCache" type="MergeSystem.Indexus.WinServiceCommon.Configuration.Client.IndexusProviderSection, MergeSystem.Indexus.WinServiceCommon"/>
</configSections>
<indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
<servers>
<add key="SrvZh03" ipaddress="127.0.0.1" port="48888" />
</servers>
<providers>
<add
name="IndexusSharedCacheProvider"
type="MergeSystem.Indexus.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, MergeSystem.Indexus.WinServiceCommon"
>
</add>
</providers>
</indexusNetSharedCache>
</configuration> 测试程序运行结果
服务端响应:
要注意的是,缓存的对象必需是可序列化的(Serializable)
出处:wuchang.cnblogs.com
-----------------------------------------------------------------------------------------
一、简介
出处:http://wuchang.cnblogs.com
indeXus.Net SharedCache是高性能的、分布式的内存对象系统,用于在动态WEB或Win应用程序中减少数据库的负责,提高访问速度。
SharedCache 全部的代码都是用c#写的,100% DotNet原生态。
先来看一下SharedCache 的几种方式:
1.Distributed Caching - partitioned
2.Replicated Caching
3.Single Instance Caching
二、小试牛刀
1.服务端
全部源码可以在SharedCache项目网站(http://www.codeplex.com/SharedCache)下载。
方案中中有7个项目
可以直接在vs2008 中打开编译。
但压缩包中缺少ICSharpCode.SharpZipLib.dll,编译前䉣准备好这个。
编译成功后MergeSystem.Indexus.WinService\bin\Debug目录的文件
job_install.bat / job_uninstall.bat 安装/卸载windows服务
job_startService.bat / job_stopService.bat 开启/停止服务
job_Console.bat 在控制台中加载服务。
如果不想安装到Windows服务中,直接用Job_Console.bat启动即可,默认监听端口是48888(在MergeSystem.Indexus.WinService.vshost.exe.config中配置),
2.测试程序
新建一个控制台程序,添加MergeSystem.Indexus.WinServiceCommon的引用。测试代码如下:
using System;
using MergeSystem.Indexus.WinServiceCommon.Provider.Cache;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
User[] data = new[] { new User{ Name="user1",Age=20},
new User{ Name="user2",Age=1},
new User{ Name="user3",Age=22}
};
foreach (var item in data)
{
IndexusDistributionCache.SharedCache.Add(item.Name, item);
}
Console.WriteLine("count={0}", IndexusDistributionCache.SharedCache.Count);
User user = IndexusDistributionCache.SharedCache.Get<User>("user2");
Console.WriteLine("name={0},age={1}", user.Name, user.Age);
Console.WriteLine("press any key to exit.");
Console.ReadKey();
}
}
[Serializable]
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
}
App.config中配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="indexusNetSharedCache" type="MergeSystem.Indexus.WinServiceCommon.Configuration.Client.IndexusProviderSection, MergeSystem.Indexus.WinServiceCommon"/>
</configSections>
<indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
<servers>
<add key="SrvZh03" ipaddress="127.0.0.1" port="48888" />
</servers>
<providers>
<add
name="IndexusSharedCacheProvider"
type="MergeSystem.Indexus.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, MergeSystem.Indexus.WinServiceCommon"
>
</add>
</providers>
</indexusNetSharedCache>
</configuration> 测试程序运行结果
服务端响应:
要注意的是,缓存的对象必需是可序列化的(Serializable)
出处:wuchang.cnblogs.com
相关文章推荐
- indeXus.Net Shared Cache - 高性能,分布式缓存方案
- indeXus.Net Shared Cache - 高性能,分布式缓存方案
- ASP.Net中的缓存方案(不仅仅是Cache和Session)(我在CSDN上和别人的争论)
- ASP.Net中的缓存方案(不仅仅是Cache和Session)(转)
- 结合高性能web站点构架话题在asp.net中petshop缓存的探究
- 使用spring3.0的cache方案解决缓存问题
- 使用 SqlCacheDependency 类在 ASP.NET 中缓存
- Asp.Net Cache缓存使用代码
- asp.net(c#)缓存Cache对象(学习日记一)
- “Velocity”-出自微软的分布式缓存方案
- ASP.NET 缓存(Cache)介绍
- 我用ASP.NET缓存之SQL数据缓存依赖(SqlCacheDependency)
- Memcached:高性能分布式对象缓存系统
- ASP.NET Cache缓存的用法
- ASP.NET 缓存(Cache)
- AggregateCacheDependency、CacheDependency、SqlCacheDependency Asp.net 2.0和PetShop4 的缓存示例
- 【原创】分布式之数据库和缓存双写一致性方案解析
- ASP.NET缓存Cache应用简单学习
- asp.net 应用数据缓存 -- Cache对象使用
- ASP.NET缓存 Cache之数据缓存