indeXus.Net Shared Cache - 高性能,分布式缓存方案
2009-04-30 11:19
477 查看
一、简介
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的引用。测试代码如下:
App.config中配置
测试程序运行结果
服务端响应:
要注意的是,缓存的对象必需是可序列化的(Serializable)
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)
相关文章推荐
- 拜年:indeXus.Net Shared Cache - 高性能,分布式缓存方案
- indeXus.Net Shared Cache - 高性能,分布式缓存方案
- ASP.Net中的缓存方案(不仅仅是Cache和Session)(转)
- ASP.Net中的缓存方案(不仅仅是Cache和Session)(我在CSDN上和别人的争论)
- 高性能的分布式内存缓存服务器系统——memcached核心原理详细剖析
- 详情ASP.NET状态管理缓存Cache应用(学习)
- asp.net 使用驻留在页面中的Cache缓存常用可定时更新的数据
- 如何构建高性能web网站:分布式缓存
- ASP.NET缓存 Cache
- asp.net Sql缓存依赖(SqlCacheDependency)简介
- 分布式系统全链路监控方案设计 - chenglinhust的专栏 - 博客频道 - CSDN.NET
- Nginx 缓存cache的5种方案
- ASP.NET cache缓存的用法
- 利用Spring.Net技术打造可切换的分布式缓存读写类
- nginx缓存cache的几种方案分析
- 高性能的分布式内存对象缓存系统Memcached
- asp.net中Session缓存与Cache缓存的区别分析
- ASP.NET状态管理之九(缓存Cache)
- ASP.NET中缓存(cache)的控制方法
- 温故知新ASP.NET 2.0(C#)(4) - Cache&SqlCacheDependency(缓存和SqlCacheDependency特性)