Memcached On PowerShell
Memcached has been around for a while, but it's still pretty neat.
Experiencing a bottleneck with your Object Relational Mappers, Services, Middleware, Database, or whatever? Then Memcached it!
Memcached was intially developed for LiveJournal by Danga Interactive in 2003, and is used by many large sites (YouTube, Amazon, Twitter, to name a few). Today, you can find a Memcached library for all your favourite languages (here's the list).
Now; cache testing is tough period, and testing Memcached (which is accessed through a telnet client) is even more difficult - it's fair to mention that there are a large number of wrappers for Memcached outside the .NET world, but I couldn't find one for that met my needs.
Introducing Memcached on Powershell
Sample usage and output
Loading the script (source can be found here)
-
PS C:\> .\memcached-on-powershell.ps1
Checking Memcached stats on an empty instance
-
PS C:\> memcached-stats 127.0.0.1 11211
-
Total items in cache: 0
-
No slabs found
Checking Memcached stats after items have been added to the cache
-
PS C:\> memcached-stats 127.0.0.1 11211
-
Total items in cache: 3
-
Stats for Slab: 1
-
Key: 'resume-service:resume:adam-kahtava'
-
Key: 'open-source-service:github:adamdotcom'
-
Key: 'open-source-service:googlecode:adam.kahtava.com'
Clearing all Memcached items
-
PS C:\> clear-memcached-items 127.0.0.1 11211
-
Total items in cache: 0
Checking Memcached stats on a cleared instance
-
PS C:\> memcached-stats 127.0.0.1 11211
-
Total items in cache: 0
-
Stats for Slab: 1
-
Empty
If your test obsessed then you might be interested in the Memcached tests.
As always feel free to contribute, view, or download the source here.
Good stuff. I wrote this a while back: http://mempowered.codeplex.com/ but I really like how you integrated the stats.