Fix has_key not supported in python3.3
Update random_key for python 3.3
Fix bug in cache.py