foyer-rs / foyer

Hybrid in-memory and disk cache in Rust
https://foyer.rs
Apache License 2.0
281 stars 20 forks source link

bug: add operaton overflow #339

Closed xiaguan closed 6 months ago

xiaguan commented 6 months ago
        Input {
            capacity: 16140894441656287227,
            cache_type: S3Fifo,
            operations: [
                Insert(
                    0,
                    15,
                    1085102592571150095,
                ),
                Insert(
                    15,
                    15,
                    18379149462045917184,
                ),
                Insert(
                    0,
                    0,
                    0,
                ),
            ],
        }
thread '<unnamed>' panicked at /home/susun/foyer/foyer-memory/src/generic.rs:229:15:
attempt to add with overflow
MrCroxx commented 6 months ago

Hi @xiaguan . Thanks for reporting it. IMO, providing an entry with a charge that causes usize overflow is not a bug. The user should guarantee that the charge is sound. And panic here is acceptable.