Click here to Skip to main content
13,291,690 members (58,793 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


Posted 26 Jul 2010

How to Enable Local Cache When Using Velocity (Microsoft Distributed Cache)

, 26 Jul 2010
Rate this:
Please Sign up or sign in to vote.
The tip explains how to enable the local cache feature of Velocity (Microsoft Distributed Cache).

Since I got this question twice this week, I'm writing this post. One of Velocity (Microsoft Distributed Cache) features is called local cache. In this tip I'll show how to enable that feature.

Velocity Client Local Cache

Local cache is a Velocity feature that can help speed up access on Velocity clients.
When enabled, a de-serialized copy of the object is saved in the client memory.
Before retrieving cached objects, the client cache will first checks whether the object exists locally and if so will get it from the local cache.

Enabling Local Cache

There are two ways to enable local cache on a Velocity client:

  • The runtime way - the DataCacheFactory object has a constructor that gets as parameter whether the local cache is enabled.
    for example:
    DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
    servers[0] = new DataCacheServerEndpoint("localhost",
                            22233, "DistributedCacheService");
    bool routingClient = false;
    // True = Enable local cache
    // False = Disable local cache
    bool localCache = true;
    var factory = new DataCacheFactory(servers,
        routingClient, localCache);
    var cache = factory.GetCache("default");

  • The configuration way - in the client config file, we we use the localCache attribute like in the following example:
    <dcacheClient deployment="simple" localCache="true">
        <host name="localhost"
              cacheHostName="DistributedCacheService" />


Local cache is a very useful feature of Velocity. It can help to boost the performance of an application that uses Velocity to new heights.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Gil Fink
Technical Lead sparXys
Israel Israel
Gil Fink is a web development expert and ASP.Net/IIS Microsoft MVP. He is the founder and owner of sparXys. He is currently consulting for various enterprises and companies, where he helps to develop Web and RIA-based solutions. He conducts lectures and workshops for individuals and enterprises who want to specialize in infrastructure and web development. He is also co-author of several Microsoft Official Courses (MOCs) and training kits, co-author of "Pro Single Page Application Development" book (Apress) and the founder of Front-End.IL Meetup. You can read his publications at his website:

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 27 Jul 2010
Article Copyright 2010 by Gil Fink
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid