1. 程式人生 > >MongoDB 的一些基本操作

MongoDB 的一些基本操作

MongoDB設定快取時間

 def __init__(self,client=None,expires=timedelta(days=30)):
        self.client = MongoClient('localhost', 27017)
        self.db=self.client.cache
        self.db.webpage.create_index('timestamp',expireAfterSeconds=expires.total_seconds())

壓縮

return record['result']

return pickle.loads(zlib.decompress(record['result']))