Skip to content

Commit

Permalink
Remove memcached support
Browse files Browse the repository at this point in the history
Apparently we had memcached support. It was never worth it, and put
a weird md5 hash calculation in the path of regular caching. Seeing
as it was completely undocumented, I doubt anyone has ever used it.
  • Loading branch information
CounterPillow committed Mar 16, 2017
1 parent b7995ef commit f1909e9
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 36 deletions.
2 changes: 0 additions & 2 deletions overviewer.py
Expand Up @@ -455,8 +455,6 @@ def set_renderchecks(checkname, num):
# Set up the cache objects to use
caches = []
caches.append(cache.LRUCache(size=100))
if config.get("memcached_host", False):
caches.append(cache.Memcached(config['memcached_host']))
# TODO: optionally more caching layers here

renders = config['renders']
Expand Down
29 changes: 0 additions & 29 deletions overviewer_core/cache.py
Expand Up @@ -22,7 +22,6 @@
"""
import functools
import logging
import cPickle

class LRUCache(object):
"""A simple, generic, in-memory LRU cache that implements the standard
Expand Down Expand Up @@ -137,31 +136,3 @@ def __delitem__(self, key):
d = self.destructor
if d:
d(link.value)

# memcached is an option, but unless your IO costs are really high, it just
# ends up adding overhead and isn't worth it.
try:
import memcache
except ImportError:
class Memcached(object):
def __init__(*args):
raise ImportError("No module 'memcache' found. Please install python-memcached")
else:
class Memcached(object):
def __init__(self, conn='127.0.0.1:11211'):
self.conn = conn
self.mc = memcache.Client([conn], debug=0, pickler=cPickle.Pickler, unpickler=cPickle.Unpickler)

def __getstate__(self):
return self.conn
def __setstate__(self, conn):
self.__init__(conn)

def __getitem__(self, key):
v = self.mc.get(key)
if not v:
raise KeyError()
return v

def __setitem__(self, key, value):
self.mc.set(key, value)
4 changes: 0 additions & 4 deletions overviewer_core/settingsDefinition.py
Expand Up @@ -103,10 +103,6 @@

processes = Setting(required=True, validator=int, default=-1)

# memcached is an option, but unless your IO costs are really high, it just
# ends up adding overhead and isn't worth it.
memcached_host = Setting(required=False, validator=str, default=None)

# TODO clean up this ugly in sys.argv hack
if platform.system() == 'Windows' or not sys.stdout.isatty() or "--simple" in sys.argv:
obs = LoggingObserver()
Expand Down
2 changes: 1 addition & 1 deletion overviewer_core/world.py
Expand Up @@ -731,7 +731,7 @@ def __init__(self, rsetobj, cacheobjects):
self.key = s

def get_chunk(self, x, z):
key = hashlib.md5(repr((self.key, x, z))).hexdigest()
key = (self.key, x, z)
for i, cache in enumerate(self.caches):
try:
retval = cache[key]
Expand Down

0 comments on commit f1909e9

Please sign in to comment.