|
1 | 1 | from __future__ import annotations |
2 | | -from typing import Optional, Callable, Any |
| 2 | +from typing import Optional, Callable, Any, Union |
3 | 3 | from collections.abc import Iterator |
4 | 4 |
|
5 | 5 | from .libcachesim_python import ReqOp, TraceType, SamplerType |
@@ -161,150 +161,150 @@ class CacheBase: |
161 | 161 | # Core cache algorithms |
162 | 162 | class LHD(CacheBase): |
163 | 163 | def __init__( |
164 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 164 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
165 | 165 | ): ... |
166 | 166 |
|
167 | 167 | class LRU(CacheBase): |
168 | 168 | def __init__( |
169 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 169 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
170 | 170 | ): ... |
171 | 171 |
|
172 | 172 | class FIFO(CacheBase): |
173 | 173 | def __init__( |
174 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 174 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
175 | 175 | ): ... |
176 | 176 |
|
177 | 177 | class LFU(CacheBase): |
178 | 178 | def __init__( |
179 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 179 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
180 | 180 | ): ... |
181 | 181 |
|
182 | 182 | class ARC(CacheBase): |
183 | 183 | def __init__( |
184 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 184 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
185 | 185 | ): ... |
186 | 186 |
|
187 | 187 | class Clock(CacheBase): |
188 | 188 | def __init__( |
189 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, init_freq: int = 0, n_bit_counter: int = 1, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 189 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, init_freq: int = 0, n_bit_counter: int = 1, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
190 | 190 | ): ... |
191 | 191 |
|
192 | 192 | class Random(CacheBase): |
193 | 193 | def __init__( |
194 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 194 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
195 | 195 | ): ... |
196 | 196 |
|
197 | 197 | # Advanced algorithms |
198 | 198 | class S3FIFO(CacheBase): |
199 | 199 | def __init__( |
200 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, small_size_ratio: float = 0.1, ghost_size_ratio: float = 0.9, move_to_main_threshold: int = 2, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 200 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, small_size_ratio: float = 0.1, ghost_size_ratio: float = 0.9, move_to_main_threshold: int = 2, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
201 | 201 | ): ... |
202 | 202 |
|
203 | 203 | class Sieve(CacheBase): |
204 | 204 | def __init__( |
205 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 205 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
206 | 206 | ): ... |
207 | 207 |
|
208 | 208 | class LIRS(CacheBase): |
209 | 209 | def __init__( |
210 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 210 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
211 | 211 | ): ... |
212 | 212 |
|
213 | 213 | class TwoQ(CacheBase): |
214 | 214 | def __init__( |
215 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, a_in_size_ratio: float = 0.25, a_out_size_ratio: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 215 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, a_in_size_ratio: float = 0.25, a_out_size_ratio: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
216 | 216 | ): ... |
217 | 217 |
|
218 | 218 | class SLRU(CacheBase): |
219 | 219 | def __init__( |
220 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 220 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
221 | 221 | ): ... |
222 | 222 |
|
223 | 223 | class WTinyLFU(CacheBase): |
224 | 224 | def __init__( |
225 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, main_cache: str = "SLRU", window_size: float = 0.01, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 225 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, main_cache: str = "SLRU", window_size: float = 0.01, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
226 | 226 | ): ... |
227 | 227 |
|
228 | 228 | class LeCaR(CacheBase): |
229 | 229 | def __init__( |
230 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, update_weight: bool = True, lru_weight: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 230 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, update_weight: bool = True, lru_weight: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
231 | 231 | ): ... |
232 | 232 |
|
233 | 233 | class LFUDA(CacheBase): |
234 | 234 | def __init__( |
235 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 235 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
236 | 236 | ): ... |
237 | 237 |
|
238 | 238 | class ClockPro(CacheBase): |
239 | 239 | def __init__( |
240 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, init_ref: int = 0, init_ratio_cold: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 240 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, init_ref: int = 0, init_ratio_cold: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
241 | 241 | ): ... |
242 | 242 |
|
243 | 243 | class Cacheus(CacheBase): |
244 | 244 | def __init__( |
245 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 245 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
246 | 246 | ): ... |
247 | 247 |
|
248 | 248 | # Optimal algorithms |
249 | 249 | class Belady(CacheBase): |
250 | 250 | def __init__( |
251 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 251 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
252 | 252 | ): ... |
253 | 253 |
|
254 | 254 | class BeladySize(CacheBase): |
255 | 255 | def __init__( |
256 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, n_samples: int = 128, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 256 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, n_samples: int = 128, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
257 | 257 | ): ... |
258 | 258 |
|
259 | 259 | # Probabilistic algorithms |
260 | 260 | class LRUProb(CacheBase): |
261 | 261 | def __init__( |
262 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, prob: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 262 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, prob: float = 0.5, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
263 | 263 | ): ... |
264 | 264 |
|
265 | 265 | class FlashProb(CacheBase): |
266 | 266 | def __init__( |
267 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, ram_size_ratio: float = 0.05, disk_admit_prob: float = 0.2, ram_cache: str = "LRU", disk_cache: str = "FIFO", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 267 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, ram_size_ratio: float = 0.05, disk_admit_prob: float = 0.2, ram_cache: str = "LRU", disk_cache: str = "FIFO", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
268 | 268 | ): ... |
269 | 269 |
|
270 | 270 | # Size-based algorithms |
271 | 271 | class Size(CacheBase): |
272 | 272 | def __init__( |
273 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 273 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
274 | 274 | ): ... |
275 | 275 |
|
276 | 276 | class GDSF(CacheBase): |
277 | 277 | def __init__( |
278 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 278 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
279 | 279 | ): ... |
280 | 280 |
|
281 | 281 | # Hyperbolic algorithms |
282 | 282 | class Hyperbolic(CacheBase): |
283 | 283 | def __init__( |
284 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 284 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
285 | 285 | ): ... |
286 | 286 |
|
287 | 287 | # Extra deps |
288 | 288 | class ThreeLCache(CacheBase): |
289 | 289 | def __init__( |
290 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, objective: str = "byte-miss-ratio", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 290 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, objective: str = "byte-miss-ratio", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
291 | 291 | ): ... |
292 | 292 |
|
293 | 293 | class GLCache(CacheBase): |
294 | 294 | def __init__( |
295 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, segment_size: int = 100, n_merge: int = 2, type: str = "learned", rank_intvl: float = 0.02, merge_consecutive_segs: bool = True, train_source_y: str = "online", retrain_intvl: int = 86400, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 295 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, segment_size: int = 100, n_merge: int = 2, type: str = "learned", rank_intvl: float = 0.02, merge_consecutive_segs: bool = True, train_source_y: str = "online", retrain_intvl: int = 86400, admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
296 | 296 | ): ... |
297 | 297 |
|
298 | 298 | class LRB(CacheBase): |
299 | 299 | def __init__( |
300 | | - self, cache_size: int | float, default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, objective: str = "byte-miss-ratio", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
| 300 | + self, cache_size: Union[int, float], default_ttl: int = 25920000, hashpower: int = 24, consider_obj_metadata: bool = False, objective: str = "byte-miss-ratio", admissioner: Optional["AdmissionerBase"] = None, reader: Optional[ReaderProtocol] = None |
301 | 301 | ): ... |
302 | 302 |
|
303 | 303 | # Plugin cache |
304 | 304 | class PluginCache(CacheBase): |
305 | 305 | def __init__( |
306 | 306 | self, |
307 | | - cache_size: int | float, |
| 307 | + cache_size: Union[int, float], |
308 | 308 | cache_init_hook: Callable, |
309 | 309 | cache_hit_hook: Callable, |
310 | 310 | cache_miss_hook: Callable, |
|
0 commit comments