I. Introduction
IndeXus. Net SharedCache is a high-performance, distributed memory object system. It is used to reduce database responsibilities in dynamic WEB or Win applications and improve access speed.
All SharedCache code is written in c #, And the 100% DotNet is original.
Let's take a look at several SharedCache methods:
1. Distributed Caching-partitioned
2. Replicated Caching
3. Single Instance Caching
Ii. Test the knife
1. Server
All source code can be downloaded from the SharedCache project website (http://www.codeplex.com/SharedCache.
There are 7 projects in the solution
You can open the compilation directly in vs2008.
However, ICSharpCode. SharpZipLib. dll is missing from the compressed package. Prepare this before compilation.
Files in the MergeSystem. Indexus. WinService "bin" Debug directory after compilation
Job_install.bat/job_uninstall.bat install/uninstall windows Services
Job_startService.bat/job_stopService.bat enable/stop the service
Job_Console.bat loads the service in the console.
Configuration in consumer. config ),
2. Test Procedures
Create a console program and add references to MergeSystem. Indexus. WinServiceCommon. The test code is as follows:
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 ;}
}
}
Configuration in 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>
Test program running result
Server Response:
Note that the cached object must be Serializable)