Spaces:
Sleeping
Sleeping
| class DRAMCache: | |
| def __init__(self, size_mb=None): | |
| """Initialize DRAM cache with unlimited capacity""" | |
| self.cache = {} | |
| self.access_order = [] | |
| self.is_unlimited = True | |
| def read(self, key): | |
| if key in self.cache: | |
| self.access_order.remove(key) | |
| self.access_order.append(key) | |
| return self.cache[key] | |
| return None | |
| def write(self, key, value): | |
| """Write to cache with unlimited capacity - no eviction needed""" | |
| if key in self.cache: | |
| self.access_order.remove(key) | |
| self.cache[key] = value | |
| self.access_order.append(key) | |
| class Buffer: | |
| def __init__(self, size_mb=None): | |
| """Initialize buffer with unlimited capacity""" | |
| self.buffer = [] | |
| self.is_unlimited = True | |
| def add(self, data): | |
| """Add data to buffer - no size restrictions""" | |
| self.buffer.append(data) | |
| def flush(self): | |
| """Flush buffer and return all data""" | |
| flushed = self.buffer[:] | |
| self.buffer = [] | |
| return flushed | |