Protobuf tree serializer fot tree-key-cache
How to Install
npm i @tree-key-cache/protobuf
How to use it
First, declare the proto file for the object you want to be the cache value:
syntax = "proto3";
package codibre.test_value;
message Value {
int32 value = 1;
}
Then, instantiate TreeKeyCache passing the proto path to getProtobufjsSerializers with the full lookup type path:
const protoPath = join(process.cwd(), 'proto/value.proto');
const lookupType = 'codibre.test_value.Value';
target = new TreeKeyCache<{ value: number }, Uint8Array>(
map,
{
keyLevelNodes: 4,
...(await getProtobufjsSerializers(protoPath, lookupType)),
},
);
And that's it! You now have a TreeKeyCache instance that serializes and deserializes using protobuf, which will save you a lot of space!
License
Licensed under MIT.