ProtoCache 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ProtoCache --version 0.1.0
                    
NuGet\Install-Package ProtoCache -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProtoCache" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtoCache" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ProtoCache" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProtoCache --version 0.1.0
                    
#r "nuget: ProtoCache, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProtoCache@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProtoCache&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ProtoCache&version=0.1.0
                    
Install as a Cake Tool

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.
  • protoc and the protoc-gen-pc.net plugin 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

BSD 3-Clause

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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