Skip to content

Commit

Permalink
Remove DBSTATS shell command, refs #244
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbgk committed Feb 22, 2017
1 parent 656cbc3 commit d81f997
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
7 changes: 0 additions & 7 deletions addok/db.py
Expand Up @@ -12,13 +12,6 @@ def connect(self, *args, **kwargs):
def __getattr__(self, name):
return getattr(self.instance, name)

def stats(self, patterns):
for pattern in patterns:
total = 0
for k in self.scan_iter(pattern):
total += self.debug_object(k)['serializedlength']
yield pattern, total


DB = RedisProxy()

Expand Down
7 changes: 0 additions & 7 deletions addok/ds.py
Expand Up @@ -28,13 +28,6 @@ def remove(self, *keys):
def flushdb(self):
_DB.flushdb()

def stats(self, patterns):
for pattern in patterns:
total = 0
for k in _DB.scan_iter(pattern):
total += _DB.debug_object(k)['serializedlength']
yield pattern, total


class DSProxy:
instance = None
Expand Down
21 changes: 0 additions & 21 deletions addok/shell.py
Expand Up @@ -231,27 +231,6 @@ def do_INTERSECT(self, words):
duration = round((time.time() - start) * 1000, 1)
print(magenta("({} in {} ms)".format(len(results), duration)))

def do_DBSTATS(self, patterns=None):
"""Print DB memory usage.
DBSTATS [pattern pattern pattern]
DBSTATS d|* w|*
Warning: this can takes a lot of time in big DB."""
if patterns:
indexes_patterns = documents_patterns = patterns.split()
else:
indexes_patterns = ['w|*', 'f|*', 'g|*', 'p|*', '*']
documents_patterns = ['d|*', '*']

formatter = Formatter()
print('Documents')
print(formatter.format(' {:<7} | {}', 'pattern', 'size'))
for pattern, size in DS.stats(documents_patterns):
print(white(formatter.format(' {:<7} | {:B}', pattern, size)))
print('Indexes')
print(formatter.format(' {:<7} | {}', 'pattern', 'size'))
for pattern, size in DB.stats(indexes_patterns):
print(white(formatter.format(' {:<7} | {:B}', pattern, size)))

def do_DBINFO(self, *args):
"""Print some useful infos from Redis DB."""
info = DB.info()
Expand Down

0 comments on commit d81f997

Please sign in to comment.