Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/backends/in_memory.py
Show All 24 Lines | def check_config(self, *, check_write): | ||||
return True | return True | ||||
def __contains__(self, obj_id): | def __contains__(self, obj_id): | ||||
return obj_id in self.state | return obj_id in self.state | ||||
def __iter__(self): | def __iter__(self): | ||||
return iter(sorted(self.state)) | return iter(sorted(self.state)) | ||||
def add(self, content, obj_id=None, check_presence=True): | def add(self, content, obj_id, check_presence=True): | ||||
if obj_id is None: | |||||
obj_id = compute_hash(content) | |||||
if check_presence and obj_id in self: | if check_presence and obj_id in self: | ||||
return obj_id | return obj_id | ||||
self.state[obj_id] = content | self.state[obj_id] = content | ||||
return obj_id | return obj_id | ||||
def get(self, obj_id): | def get(self, obj_id): | ||||
Show All 27 Lines |