Demo / Gomoku_Bot /cache.py
HuskyDoge's picture
added gomokubot
7d23b62
raw
history blame
603 Bytes
from cachetools import LRUCache
from .config import config
class Cache:
def __init__(self, capacity=1000000):
self.capacity = capacity
self.cache = LRUCache(maxsize=capacity)
self.enable_cache = config['enableCache']
def get(self, key):
if not self.enable_cache:
return None
return self.cache.get(key, None)
def put(self, key, value):
if not self.enable_cache:
return
self.cache[key] = value
def has(self, key):
if not self.enable_cache:
return False
return key in self.cache