ASP. NET Distributed Cache

Source: Internet
Author: User

The velocity has been integrated into app Fabric with WCF monitor = =.

Network velocity is mostly used for older versions:
Old version of: http://www.microsoft.com/en-us/download/details.aspx?id=2517

Here are some instructions for app Fabric:

1. Use in VS 2010:

1) reference in the installation directory of the app fabric:

Microsoft.ApplicationServer.Caching.Client.dll

Microsoft.ApplicationServer.Caching.Core.dll

Microsoft.ApplicationServer.Caching.Core.dll is the cache base Class library, both the cache client and the server reference the DLL, which contains the configuration library and the base class cache type.

Microsoft.ApplicationServer.Caching.Client.dll contains the cache client class library, such as the API interface that connects to the cache cluster store and retrieve data, and so on.

2) configuration in Web. config (refer to: http://msdn.microsoft.com/zh-cn/library/ee790859 (v=azure.10). aspx)

<configSections>
<section name= "datacacheclient" type= "Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core, version=1.0.0.0, culture=neutral,publickeytoken=31bf3856ad364e35 "/>
</configSections>
<dataCacheClient>
</dataCacheClient>

3) Code:

String key = "ApplicationName";
var DCF = new Datacachefactory ();

if (DCF! = NULL)
{
var cache = DCF. GetCache ("default"); This should be a valid cache name for the cache server, or it will be an error.
Name = cache. Get (key) as String;
if (name = = NULL)
{
Name = "Windows Server App Fabric Cache Lab";
Cache. Put (key, name);
}
}

Ways to query the cache name in the Power Shell tool:


2. No configuration file connection cache is used in VS2010

datacacheserverendpoint[] Servers = new DATACACHESERVERENDPOINT[1];
Servers[0] = new Datacacheserverendpoint ("host name of the cache server", 22233);

Setup the datacachefactory configuration.
Datacachefactoryconfiguration factoryconfig = new Datacachefactoryconfiguration ();
Factoryconfig.servers = Servers;

Create a configured Datacachefactory object.
Datacachefactory mycachefactory = new Datacachefactory (factoryconfig);

Get a cache client for the cache "NamedCache1".
Datacache Mydefaultcache = Mycachefactory.getcache ("Default");
Mydefaultcache.put ("ApplicationName1", "VVVV");
Object v = mydefaultcache.get ("ApplicationName1");

Common Power shell commands:

1. Get-command *cache*: Find the command with the cache keyword

2. Get-cache: Gets the cache name of the current server

3. New-cache: Create a new cache. New cache nodes are automatically added in the cache server share configuration file
Example: New-cache ' AAA '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.