A short overview of cache providers, part 2

The short overview of cache providers continues with two more of them – NCache and Velocity.


As a surprise – it doesn’t come free! So our (my) expectations should be even higher. But hey – it has a free option as well! So – what we get from NCache?

  • Enterprise Library pluggability – this can be useful, but doesn’t seem to be unachievable using the other providers as well…
  • HttpModule for 1.1, Session handling module for 2.0/3.0/3.5 for putting asp.net session into cache
  • Can handle java and .net clients natively
  • You have the option to build complex hiearchies, clusters, etc

So – this looks like heaven, or not? The trick lies in the limitations for the free version:

  • Only a maximum of 2 servers supported
  • Cache clients should be either local or from the second cache server
  • Only the replicated cache topology can be used
  • No support for session state/output cache (means no module)
  • 32-bit only (which would mean a 2 Gig cap on cache size, but it’s limited as of 500 Mb anyway…)
  • No java clients, no remote .net clients
  • No SQL dependency
  • No event notifications (!)
  • No GUI tool

So most of the limitations are rock solid and stops me from using this, sorry…

Microsoft Velocity

Microsoft Velocity is anotherdistributed cache platform for in-memory caches spread across multiple computers. The Velocity API is in managed code, and as usual – any serializable managed object can be in the cache. So let’s look at the bells and whistles and the downsides:

  • It’s running as a 32bit process – in order to use more than 2Gigs you have to run more of them
  • It has session state provider module for asp.net
  • It supports regions as another level of separation as well as asynch communication, locking and TTL
  • Planned support for failover, replicated cache (currently only local/partitioned/routed available) and eventing

So if it’s at least as good as the others why not using it today? I have to admit – I’d miss many of the planned features… And as it looks like currently, CTP2 is on the way to be delivered at PDC, and RTM is targeted to be in H1CY09…

Of course – this is not a full list. If you know any cache provider you think may worth showing here – don’t hesitate. And I’ll try to come to a conclusion in the part 3 – so be prepared!

Technorati tags: , , ,

Open Source Series 2.: NVelocity (part 2)

I forgot an important part of the previous posts – I was talking about many projects using the original Velocity for many purposes – but is the .NET version used? I tried to put together a noncomprehensive list of usages – feel free to comment to add your own! One important thing – currently there are 2 branches on NVelocity – one can be found at http://nvelocity.sf.net, the other is part of Castle – use the latter one, it has more bells and support as well 🙂

This post is part of the open source series

Open Source Series 2.: NVelocity

Formerly as part of the Apache Jakarta project, now part of the Apache project itself can be found the Velocity project. Since the beginning, it is the de facto tool for generating template driven applications – websites, documents, etc., the list of projects, websites and tools powered by or capable of using Velocity is endless. As for other great and successfull projects (like Hibernate, which also uses velocity for generating POJO files), this was met with the new wind of .NET – there were NVelocity born. So to make it short – NVelocity is a .Net-based template engine – it permits anyone to use the simple yet powerful template language called VTL to reference objects, execute methods, etc defined in .Net code. Speaking of a web application, this leads to the MVC pattern – this simple to use and set up tool enables you to program against modells in your views, and put the controller in charge of binding the two – this (and NHibernate, and ActiveRecord, and Windsor…) is what lead to the born of the Castle and the Rhino projects – but these are in later post :).

So no whistles nor bells, but the main part of NVelocity is:

  • You create the engine – new NVelocity.App.VelocityEngine(ep);
  • You get a template – engine.GetTemplate(“template.vm”);
  • You create a context – new NVelocity.VelocityContext();
  • You fill the context – context.Put(“key”, “value”);
  • Than you merge the context with the template using the engine – template.Merge(context, outputStream);

The extras are coming mostly in the template file, and by the fact, that there are plenty of way to provide plugins into the system – ResourceLoaders for determining where to get the file (from the filesystem? database? embedded resource?), caches of various parts, etc. So, back to template file – what can I do?

  • I can print the value for a key – ${key}
  • I can use property getters and setters – #set ${object}.prop = “value”
  • I can use loops, if-then-else, define macros, etc
  • Call and return any method with parameterlists which may contain values, arrays, dictionaries, etc – ${object}.Method(${key}, “%{key = ‘value’, key2 = ${key}}”);
  • Meanwhile the whole thing is typesafe and – the template gets compiled into an AST tree the first time it met!

So – I think this is a very handy tool for generating source files, for generating documents and for driving data driven websites.

PS: No, it has nothing to do with Microsoft Velocity – that goes into the cache providers series 🙂

This post is part of the open source series