Skip to content

Commit

Permalink
Merge pull request #2 from grahamking/master
Browse files Browse the repository at this point in the history
Added ability to run it from command line to list keys.
  • Loading branch information
dlrust committed Sep 20, 2011
2 parents ab5d250 + d2e6efe commit c9f7427
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,14 @@ Retrieve a list of keys currently in use:
'key-3',
... ]

## List the keys

If you just want to list some of the keys in memcached, run this from the command line:

python -m memcached_stats <ip> <port>

ip defaults to 127.0.0.1 and port defaults to 11211.

## Installation

pip install 'git+git://github.com/dlrust/python-memcached-stats.git'
Expand Down
14 changes: 13 additions & 1 deletion src/memcached_stats.py
@@ -1,4 +1,4 @@
import re, telnetlib
import re, telnetlib, sys

class MemcachedStats:

Expand Down Expand Up @@ -43,3 +43,15 @@ def slab_ids(self):
def stats(self):
' Return a dict containing memcached stats '
return dict(self._stat_regex.findall(self.command('stats')))

def main(argv=None):
if not argv:
argv = sys.argv
host = argv[1] if len(argv) >= 2 else '127.0.0.1'
port = argv[2] if len(argv) >= 3 else '11211'
import pprint
m = MemcachedStats(host, port)
pprint.pprint(m.keys())

if __name__ == '__main__':
main()

0 comments on commit c9f7427

Please sign in to comment.