def del_item(self, userid, item): version = get_new_version() data, casid = self.get_cached_data(userid) num_deleted = self._del_items(userid, [item], version, data, casid) if num_deleted == 0: raise ItemNotFoundError return version
def __init__(self, storage): self.storage = storage self.connection = storage.dbconnector.connect() self.new_version = get_new_version() self.timestamp = time.time() self.cache = defaultdict(SQLCachedCollectionData) self.locked_collections = set() self._nesting_level = 0
def set_item(self, userid, item, bso): bso["id"] = item version = get_new_version() data, casid = self.get_cached_data(userid) num_created = self._set_items(userid, [bso], version, data, casid) return { "created": num_created == 1, "version": version, }
def del_items(self, userid, items): version = get_new_version() data, casid = self.get_cached_data(userid) self._del_items(userid, items, version, data, casid) return data["version"]
def del_collection(self, userid): if not self.cache.delete(self.get_key(userid)): raise CollectionNotFoundError return get_new_version()
def set_items(self, userid, items): version = get_new_version() data, casid = self.get_cached_data(userid) self._set_items(userid, items, version, data, casid) return version