CacheFabric

Last Update
18 June 2013
Regular License
$10
Extended License
$50
Sales
12

CacheFabric is a powerful and easy to use component that brings the power of flexible caching to your .NET applications.

What are the advantages?

Reduce load on Web Services / Database – Great for increasing the number of users your application can handle simultaneously (Scale). Increase Performance – Meet yours users’ needs in functionality and application responsiveness. Reliability – Failing components could be masked by the cache while repairs/restarts are done. It greatly reduces overhead from server resources. Reserve server capacity for non-cacheable content and other operations. Achieve capital expenditure and operational savings by optimizing server utilization. Reduce content delivery times by serving content from fast memory cache storage.

CacheFabric can be used in all .NET applications by simply selecting the appropriate caching mechanism. All the various caching mechanisms are built on the same foundation therefore there will never be a need to change your code, just simply instantiate a different component and switch to a different caching mechanism.

What are the available caching components?

ASP.NET Native Cache (Single Server) – ASP.NET has a powerful, easy-to-use caching mechanism that allows you to store objects in memory that require extensive server resources to create. Caching these types of resources can significantly improve the performance of your application. Only to be used in web applications. Enterprise Library Cache (Single Server – Any .NET platform) – The Enterprise Library Caching Application Block lets developers incorporate a local cache in their applications. It supports both an in-memory cache and, optionally, a backing store that can either be the database store or isolated storage. The application block can be used without modification; it provides all the functionality needed to retrieve, add, and remove cached data. Configurable expiration and scavenging policies are also part of the application block. Can be used in all .NET applications. AppFabric Cache (Distributed Caching – Any .NET platform) – Microsoft AppFabric 1.1 for Windows Server is a set of integrated technologies that makes it easier to build, scale, and manage Web and composite applications that run on IIS. Can be used in all .NET applications. NULL Caching (Turn off caching) – Stop caching without changing your code. Can be used in all .NET applications and is very effective when unit testing when the development or production caching framework is not available

An extremely powerful feature of CacheFabric is the ability to access Microsoft’s offering into the distributed caching arena – AppFabric. While the AppFabric system is very powerful there are few resources available that enables easy access – this is where CacheFabric comes in to its own.

AppFabric Highlights

CacheFabric provides a great way of accessing this cache. It’s simple, easy and provides additional features that even out of the box AppFabric does not support.

Sliding expiration Automatic retry on failure

CacheFabric also manages many types of AppFabric exceptions by ignoring, retrying, or passing the exception on to the client. CacheFabric handles the following errors:

Key already exists Key does not exist Region does not exist Named cache does not exist Timeout Retry later Cache server unavailable Throttled

Connection terminated

COMPLETE INTEGRATION: CacheFabric is completely integrated with all the caching mechanism thereby allowing external access of these components (the complete power of the cache, configuration, and features are still available). They will work together.

BONUS FEATURE: Consistent & unique cache key generation based on method or class. Use when you do not care what the cache key is called but will always be used in the same method or class.

What do you get in the package?

.NET 3.5 Assemblies Debug files (PDB) XML comments (Intellisense) Usage documentation Documented API Console demo application MVC 3 demo application WebForms demo application C# Source Code Visual Studio 2010 SP1 & 2012 Solution

Technologies

This component is built using the .NET 3.5 Framework which means in can be used in all .NET applications that are using the 3.5 framework or newer. This includes .NET 3.5, 4.0, & 4.5+.

You can immediately use this within your application and is very simple. Ask any questions or suggest features at support.avantprime.com!

How would I use it?

using System; using System.Diagnostics; using System.Net; using AvantPrime.CachFabric; using Microsoft.Practices.EnterpriseLibrary.Caching;

namespace AvantPrime.CacheFabric.TestConsole { class Program { static readonly ICacheManager CacheManager = Microsoft.Practices.EnterpriseLibrary.Caching.CacheFactory.GetCacheManager(); static readonly ICacheDirector Cache = new EnterpriseLibraryCache(CacheManager);

static void Main(string[] args) { var stopwatch = new Stopwatch(); var website = "http://www.microsoft.com";

stopwatch.Start(); Console.WriteLine("Warmup Run"); LoadWebsiteData(website, false); stopwatch.Stop(); Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);

stopwatch.Reset(); stopwatch.Start(); Console.WriteLine("No Cache Run"); LoadWebsiteData(website, false); stopwatch.Stop(); Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);

stopwatch.Reset(); stopwatch.Start(); Console.WriteLine("Cached Run"); LoadWebsiteData(website, true); stopwatch.Stop(); Console.WriteLine("Elapsed time: {0}ms", stopwatch.ElapsedMilliseconds);

Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }

private static string LoadWebsiteData(string webAddress, bool useCache) { string data = null; string cacheKey = CacheKeys.GetMethodKey(webAddress);

if (useCache) { data = Cache.Get(cacheKey) as string; }

if (data == null) { using (var client = new WebClient()) { data = client.DownloadString(webAddress); Cache.Add(cacheKey, data); } }

return data; } } }