-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
It seems that this module only supports Vector{UInt8} keys and values, which makes it pretty unusable.
Why not add support for general types?
E.g. something like:
using LevelDB
using Serialization
function obj2buf(t::T) where T
io = IOBuffer()
serialize(io, t)
return take!(io)
end
buf2obj(v::Vector{UInt8}) = deserialize(IOBuffer(v))
Base.setindex!(db::LevelDB.DB, i::T, v::S) where {T,S} = Base.setindex!(db, obj2buf(i), obj2buf(v))
Base.getindex(db::LevelDB.DB, i::T) where T = buf2obj(Base.getindex(db, obj2buf(i)))
...
db = LevelDB.DB("level.db", create_if_missing = true)
db["aa"] = "bb"
db["aa"]
# "aa"Obviously, a faster/more stable serialization should be used -- e.g. code from JLD2 could be used.
Metadata
Metadata
Assignees
Labels
No labels