updated for shelve. a temporary (or maybe permanent?) solution while we figure out Mongo stuff. tried to mark what's legacy Mongo code and what's not but it's a bit confusing. I saved the old Mongo-based botcache.py in case we need it