Skip to main content

memorydb-django

Django cache and session backends for MemoryDB. Two lines in settings.py, the way sqlite3 is a drop-in for Django itself — no models, no migrations, no new code in your views.

pip install memorydb-django
# settings.py
CACHES = {"default": {
    "BACKEND": "memorydb_django.MemoryDBCache",
    "LOCATION": "memorydb://TOKEN@127.0.0.1:8080",   # or leave empty and set MEMORYDB_URL
}}

SESSION_ENGINE = "memorydb_django.sessions"
MEMORYDB_URL = "memorydb://TOKEN@127.0.0.1:8080"   # the session store reads this, not CACHES

Then use Django's own API:

from django.core.cache import cache
cache.set("hero", {"name": "Karna"}, timeout=30)   # one record; the TTL is the record's expiry
cache.get("hero")

request.session["user_id"] = 42                    # SESSION_COOKIE_AGE enforced server-side
request.session.save()

Details worth knowing:

  • Each cache key and each session is one MemoryDB document in the django_cache / django_sessions collection (typed, unique and indexed; created on first use).
  • The session engine has no LOCATION of its own: CACHES configures the cache only. Sessions take their connection from the MEMORYDB_URL Django setting, or, if you do not set it, from the MEMORYDB_URL environment variable (with MEMORYDB_TOKEN optional). Following the snippet above but leaving out that one line is the usual way to meet ValueError: pass a url with token=, a memorydb:// connection string, or set MEMORYDB_URL — it is raised on the first session read, not at startup.
  • timeout= and SESSION_COOKIE_AGE are stored as the record's own expires field, so the server stops serving them at the deadline. No cleanup cron, and clear_expired() is a no-op.
  • Concurrent writers use optimistic versions and retry, so there are no row locks or deadlocks.
  • Set MEMORYDB_SESSIONS_COLLECTION / OPTIONS["collection"] to move either store elsewhere, so two Django projects on one server stay apart.
  • Session values are stored through Django's own SESSION_SERIALIZER and signed with your SECRET_KEY, exactly as the database-backed store signs them, so sessions your site already issued keep working when you switch engines.

This is a cache/session backend, not a django.db backend — models, migrations, the admin and ORM queries still need Postgres or SQLite.

Metadata

Release files for memorydb-django 0.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memorydb-django 0.2.8
File Size Uploaded Provenance Actions
memorydb_django-0.2.8.tar.gz 5.0 kB With provenance Details for memorydb_django-0.2.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memorydb-django 0.2.8
File Interpreter ABI Platform Actions
memorydb_django-0.2.8-py3-none-any.whl Python 3 none any Details for memorydb_django-0.2.8-py3-none-any.whl

Total release size: 11.2 kB

Release files / memorydb_django-0.2.8.tar.gz

Download URL memorydb_django-0.2.8.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ce4e8cc41bf02564567d5238a9279a0b68a4a21c3aadc472a528f6309d8c4e77
BLAKE2b-256 checksum
How to use checksums
c6f77a1e0b79b6b1db14a12935200937ecc8fd0e9d191cbc6641f00d38545e8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / memorydb_django-0.2.8-py3-none-any.whl

Download URL memorydb_django-0.2.8-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa2226f0deb0ebe07420145b378a225f4236a3acdc270a178e80e276f971bc8c
BLAKE2b-256 checksum
How to use checksums
179e61a03e45755f9f29ebbc42ca434ccc4d308551b846acc9b37094471634a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for memorydb-django 0.2.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for memorydb_django-0.2.8.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page