ProtoCache 0.1.0
See the version list below for details.
dotnet add package ProtoCache --version 0.1.0
NuGet\Install-Package ProtoCache -Version 0.1.0
<PackageReference Include="ProtoCache" Version="0.1.0" />
<PackageVersion Include="ProtoCache" Version="0.1.0" />
<PackageReference Include="ProtoCache" />
paket add ProtoCache --version 0.1.0
#r "nuget: ProtoCache, 0.1.0"
#:package ProtoCache@0.1.0
#addin nuget:?package=ProtoCache&version=0.1.0
#tool nuget:?package=ProtoCache&version=0.1.0
ProtoCache .NET
Alternative flat binary format for Protobuf schema. It works like FlatBuffers, but it's usually smaller and supports map. The format is flat, so numeric fields and nested structures can be accessed without full message deserialization. In the current C# implementation, some APIs still allocate when reading strings or wrapper objects. A benchmark shows that Protobuf has considerable deserialization overhead and significant reflection overhead. FlatBuffers is fast but wastes space. ProtoCache takes a balance between data size and read speed, so it's useful in data caching.
| Protobuf | ProtoCache | FlatBuffers | |
|---|---|---|---|
| Data Size | 574B | 780B | 1296B |
| Decode + Traverse | 2805ns | 1139ns | 2353ns |
The C# version is not fully zero-copy yet, so benchmark results should be interpreted as "low-deserialization-overhead access" rather than literal zero-allocation traversal.
See details in the C++ version.
Requirements
- .NET 10 or later.
protocand theprotoc-gen-pc.netplugin when generating typed accessors.
Installation
The first public releases are prerelease packages:
dotnet add package ProtoCache --prerelease
Code generation
A protobuf compiler plugin called protoc-gen-pc.net is available in the
ProtoCache C++ repository.
Build or install the plugin where protoc can find it, then generate the C#
accessors:
protoc --pc.net_out=. test.proto
The generated files are intentionally short and readable. Keep the runtime package and generator compatible when upgrading.
Basic API
var pb = pb.Main.Parser.ParseFrom(raw);
raw = ProtoCache.Serialize(pb);
var root = new pc.Main(raw);
Serializing a protobuf message with ProtoCache.Serialize is the only way to create protocache binary at present. It is easy to access by wrapping the data with generated code. Numeric and bytes fields use direct zero-copy access; strings and some object-oriented helpers may still allocate. Convert a bytes field to an owned array explicitly with root.Data.ToArray() when needed.
Reflection
TODO
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Google.Protobuf (>= 3.30.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.1 | 80 | 8/5/2026 |
| 0.1.0 | 81 | 7/29/2026 |
| 0.1.0-preview.1 | 69 | 7/28/2026 |