From 6137bc48ddf5cc8f00dde211e65a7056a3e7658d Mon Sep 17 00:00:00 2001
From: Erik Webb <erik@erikwebb.net>
Date: Sun, 12 May 2013 19:25:36 -0400
Subject: [PATCH] Feature #1993170 by erikwebb: Add Drush command to retrieve
 Memcached values

---
 memcache.drush.inc | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 memcache.drush.inc

diff --git a/memcache.drush.inc b/memcache.drush.inc
new file mode 100644
index 0000000..1b3d229
--- /dev/null
+++ b/memcache.drush.inc
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * @file
+ * Drush integration for the Memcache module.
+ */
+
+/**
+ * Implements hook_drush_command().
+ */
+function memcache_drush_command() {
+  $items['memcache-get'] = array(
+    'description' => dt('Retrieve a single value from Memcached.'),
+    'arguments' => array(
+      'key' => dt('The key with which the item was stored.'),
+      'bin' => dt('The bin in which the item was stored. Default is \'cache\'.'),
+    ),
+    'required-arguments' => 1,
+    'examples' => array(
+      'memcache-get variables cache_bootstrap' => 'Output the variables cache.',
+    ),
+    'aliases' => array('mcget'),
+  );
+  return $items;
+}
+
+function drush_memcache_get($key, $bin = 'cache') {
+  require_once dirname(__FILE__) . '/memcache.inc';
+
+  if (($item = dmemcache_get($key, $bin)) === FALSE) {
+    drush_log(dt('Unable to find key @key in bin @bin.', array('@key' => $key, '@bin' => $bin)), 'warning');
+  }
+  else {
+    drush_print($key . ' => ' . !is_null($item) ? print_r($item, TRUE) : dt('NULL'));
+  }
+}
-- 
1.8.1.3

