Skip to main content

Dead simple cache for unwieldily joined relations.

Project description

tablecache

Dead simple cache for unwieldily joined relations.

Copyright and license

Copyright 2023 Marc Lehmann

This file is part of tablecache.

tablecache is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

tablecache is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with tablecache. If not, see https://www.gnu.org/licenses/.

Purpose

tablecache is a small library that caches tables in a slow database (or, more likely, big joins of many tables) in a faster storage.

Suppose you have a relational database that's nice and normalized (many tables), but you also need fast access to data resulting from joining a lot of these tables to display somewhere.

tablecache can take your big query, and put the denormalized results in faster storage. When data is updated in the DB, the corresponding key in cache can be invalidated to be refreshed on the next request.

Usage

The main components when using the library are a DB table abstraction (PostgresTable), a storage table abstraction (RedisTable), and a CachedTable tying the 2 ends together.

The storage needs to encode and decode the data (to/from bytes). This is done via codecs. Some basic ones are provided (tablecache.*Codec).

Check out examples/users_cities.py for a quick start, which should be pretty self-explanatory.

Limitations

Currently, only Postgres is supported as DB, and only Redis as the fast storage.

The library assumes that the query to be cached has a (single) column acting as primary key, i.e. one which uniquely identifies a row in the result set of the query.

At the moment, the Redis storage supports only one table, which takes up the entire keyspace of the connected Redis instance.

Project details


Download files

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

Source Distribution

tablecache-2.0.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

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

tablecache-2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file tablecache-2.0.tar.gz.

File metadata

  • Download URL: tablecache-2.0.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tablecache-2.0.tar.gz
Algorithm Hash digest
SHA256 a867cdf0da679705e60860c5ff034477b9b920c82a5de0d6f2b7e1b1081ae7f9
MD5 ce73c32bf352bcfc9a664685944b5492
BLAKE2b-256 153f4013c41f897450f930e4bdd5abe9c5e36362b0f6f9413849d16d9ec35a17

See more details on using hashes here.

File details

Details for the file tablecache-2.0-py3-none-any.whl.

File metadata

  • Download URL: tablecache-2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for tablecache-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f409bde0b19b76e6606b9b9b99c5054e4bc2b867a7f12461053d155a1825fd7e
MD5 f992e9377da8c16b4278fba8eb5a2edb
BLAKE2b-256 68d53f0f714f5fb03fb9171e18800337fe40ec49e8cb04bd94c5aa8d4a30b77a

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