Spaces:
Sleeping
Sleeping
File size: 1,116 Bytes
e9bc512 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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
|