Skip to main content

Versioned key-value store with git-like commit, branch, and merge semantics.

Project description

kvgit 🔀

Versioned key-value store with git-like commit, branch, and merge semantics.

Values are Any (serialized via pickle by default). Commits are content-addressable. Branches are cheap. Merges are three-way with pluggable per-key conflict resolution.

Features

  • Commits -- immutable, content-addressable snapshots
  • Branches -- named branch heads with CAS-based concurrency
  • Three-way merge -- auto-merges non-overlapping changes, pluggable merge functions for conflicts
  • Merge functions -- counters, last-writer-wins, or custom per-key merge logic
  • Garbage collection -- high/low water rebase drops cold keys automatically
  • Namespaces -- key-prefixed views with full read/write support
  • Pluggable backends -- in-memory, disk (via diskcache), or bring your own KVStore

Install

pip install kvgit            # in-memory only
pip install kvgit[disk]      # adds disk backend via diskcache

Quick example

import kvgit

# Create a store -- values are Any (pickle-serialized by default)
s = kvgit.store()

s["user"] = "alice"
s["score"] = 0
s.commit()

first = s.current_commit

# Update and commit again
s["score"] = 100
s.commit()
print(s["score"])              # 100

# Rollback to the first commit
s.reset_to(first)
print(s["score"])              # 0

# Branching
s["score"] = 50
s.commit()

dev = s.create_branch("dev")
dev["score"] = 999
dev.commit()

print(s["score"])              # 50  (main unchanged)
print(dev["score"])            # 999 (dev branch)

Development

uv sync --extra dev
uv run pytest

Documentation

See docs/ for detailed API documentation:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kvgit-0.1.4-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file kvgit-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: kvgit-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for kvgit-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aeb7261ed37b3f1458da6e885f46c8d22bf0ff6e7749a7ede619dbfd06fc79b0
MD5 e2c03e611e74332cdd5c461337fc2e3b
BLAKE2b-256 23c700b12ad7a21f3487fcd8c897ac93cfbb5c6cc93f63798b693d6d220e7541

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page