Skip to content

Serialization does not support non-default by functions #51

Open
@justinmimbs

Description

@justinmimbs

The serialization extension assumes that currentsize is always measured by the number of items in the LRU.

If we use another by function to measure size, then we error trying to serialize (which is good because it looks like deserialize depends on this assumption).

using LRUCache
using Serialization

lru = LRU{String,Vector{UInt8}}(; maxsize = 1024, by = sizeof)
lru["asdf"] = rand(UInt8, 512)

# not the same
@assert lru.currentsize == 512
@assert length(lru) == 1

serialize(IOBuffer(), lru)
# ERROR: AssertionError: lru.currentsize == length(lru)

Would a PR contribution be welcome to help here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions