{"id":331,"date":"2008-06-03T20:56:34","date_gmt":"2008-06-04T01:56:34","guid":{"rendered":"http:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/331"},"modified":"2008-06-03T20:56:34","modified_gmt":"2008-06-04T01:56:34","slug":"velocity-a-rockin-distributed-in-memory-cache-for-aspnet","status":"publish","type":"post","link":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/331","title":{"rendered":"Velocity — a rockin’ distributed in memory cache for ASP.NET"},"content":{"rendered":"
Velocity, the code-name for a new in-memory distributed caching system for ASP.NET was released as a Community Tech Preview today.<\/p>\n
What is it? It’s described in the documentation:<\/p>\n
\nMicrosoft project code named “Velocity” provides a highly scalable in-memory application cache for all kinds of data. By using cache, your application performance can improve significantly by avoiding unnecessary calls to the data source. <\/p>\n
By using distributed cache, your application can scale to match an increasing demand with increasing throughput. “Velocity” distributed cache is provided in the form of a cache cluster, simplifying your application code by managing the complexities of load balancing behind the scenes. <\/p>\n
When you use “Velocity,” you can retrieve data by using keys or other identifiers, called tags. <\/p>\n<\/blockquote>\n
Download for CTP 1 is here<\/a>.<\/p>\n
Run the installation — and at the end you’ll be asked a few simple starter questions:<\/p>\n
<\/a> <\/p>\n
The settings above can be adjusted later if you don’t like them. Unblock the EXE in your firewall settings if needed (I didn’t need to when using localhost as my destination server as shown below).<\/p>\n
<\/a> <\/p>\n
Installed. Create a new web site in Visual Studio 2008:<\/p>\n
<\/a><\/p>\n
Add a reference to pull in the necessary settings into your web site: <\/p>\n
<\/a> <\/p>\n
You’ll need to reference a few assemblies. The simplest way to get them all is to reference them directly (rather than copying them as the instructions say). VS 2008 won’t complain.The following files are needed:<\/p>\n
CacheBaseLibrary.dll<\/b>, ClientLibrary.dll<\/b>, FabricCommon.dll<\/b>, CASBase.dll<\/b>, and CASClient.dll<\/b><\/p>\n
<\/p>\n
<\/a> <\/p>\n
Next, adjust the web.config file per the instructions. <\/p>\n
I tweaked the dcacheClient settings to match those I set when the first installed Velocity.<\/p>\n
<<\/span>dcacheClient <\/span>deployment<\/span>=<\/span>\"simple<\/span>\" localCache<\/span>=<\/span>\"false<\/span>\">\n <<\/span>hosts<\/span>>\n <!--<\/span>List of hosts <\/span>-->\n <<\/span>host <\/span>name<\/span>=<\/span>\"localhost<\/span>\" cachePort<\/span>=<\/span>\"22233<\/span>\" cacheHostName<\/span>=<\/span>\"MyCluster<\/span>\"\/>\n <\/<\/span>hosts<\/span>>\n<\/<\/span>dcacheClient<\/span>><\/span><\/pre>\n
<\/a><\/a><\/p>\n
I added the required sections to the configSections in web.config, and also the “fabric” section:<\/p>\n
<<\/span>configuration<\/span>>\n <<\/span>configSections<\/span>>\n<\/span><\/pre>\n
<\/a><\/p>\n
<<\/span>section <\/span>name<\/span>=<\/span>\"dcacheClient<\/span>\" type<\/span>=<\/span>\"System.Configuration.IgnoreSectionHandler<\/span>\" allowLocation<\/span>=<\/span>\"true<\/span>\" allowDefinition<\/span>=<\/span>\"Everywhere<\/span>\"\/>\n <<\/span>section <\/span>name<\/span>=<\/span>\"fabric<\/span>\" type<\/span>=<\/span>\"System.Fabric.Common.ConfigFile, FabricCommon<\/span>\" allowLocation<\/span>=<\/span>\"true<\/span>\" allowDefinition<\/span>=<\/span>\"Everywhere<\/span>\"\/>\n<\/span><\/pre>\n
<\/a><\/p>\n
<\/<\/span>configSections<\/span>><\/span><\/pre>\n
<\/a><\/p>\n
<<\/span>fabric<\/span>>\n <<\/span>section <\/span>name<\/span>=<\/span>\"logging<\/span>\" path<\/span>=<\/span>\"\">\n <<\/span>collection <\/span>name<\/span>=<\/span>\"sinks<\/span>\" collectionType<\/span>=<\/span>\"list<\/span>\">\n <<\/span>customType <\/span>className<\/span>=<\/span>\"System.Fabric.Common.EventLogger,FabricCommon<\/span>\" sinkName<\/span>=<\/span>\"System.Fabric.Common.ConsoleSink,FabricCommon<\/span>\" sinkParam<\/span>=<\/span>\"\" defaultLevel<\/span>=<\/span>\"-1<\/span>\"\/>\n <<\/span>customType <\/span>className<\/span>=<\/span>\"System.Fabric.Common.EventLogger,FabricCommon<\/span>\" sinkName<\/span>=<\/span>\"System.Fabric.Common.FileEventSink,FabricCommon<\/span>\" sinkParam<\/span>=<\/span>\"CacheClientLog<\/span>\" defaultLevel<\/span>=<\/span>\"1<\/span>\"\/>\n <<\/span>customType <\/span>className<\/span>=<\/span>\"System.Fabric.Common.EventLogger,FabricCommon<\/span>\" sinkName<\/span>=<\/span>\"System.Data.Caching.ETWSink, CacheBaseLibrary<\/span>\" sinkParam<\/span>=<\/span>\"\" defaultLevel<\/span>=<\/span>\"-1<\/span>\"\/>\n <\/<\/span>collection<\/span>>\n <\/<\/span>section<\/span>>\n <\/<\/span>fabric<\/span>>\n<\/span><\/pre>\n
<\/a><\/p>\n
<\/<\/span>configuration<\/span>><\/span><\/pre>\n
<\/a><\/p>\n
Added some code, then run (the code I used is shown below).<\/p>\n
<\/p>\n
Unfortunately, this is the first error I encountered:<\/p>\n
Access to the path ‘C:\\Windows\\system32\\CacheClientLog.log’ is denied.<\/i><\/p>\n
Since I’m using the ASP.NET Development Server, I started an administrative instance of notepad and created a blank CacheClientLog.log file in the directory. I then set full permissions on the file for my user account (aaron in my case). <\/p>\n
Next, I discovered that the service EXE hadn’t been properly installed. After some false-starts, I rebooted, and again, as an admin user, used the installutil.exe utility from the .NET SDK to install the service (as I had uinstalled it). Using the Services management console, I started the service, “DistributedCacheService.”<\/p>\n
Using the Velocity Administration tool, I verified that the host was now running:<\/p>\n