Skip to main content

DistCache (Distributed Cache)

Distcache is a open-source distributed in-memory cache and database. Operations are mostly asynchronous to achieve high performance. It is implemented purely in python without any external dependency which should make it easier to install and get started with. One of design goal of this project is ease of use and less cognitive load to users of similar caching/database systems like Redis, Memcached.

See wiki or readthedocs for extensive documentation.

Build and test status

Features

  1. Data types supported:
    • All basic data types and their combination. For instance, int, str, dict, set, tuple, list, etc and their objects that have only these types as their attributes are supported.
    • You can even read any object (image, pdfs, etc) in binary format and save them as key, value pair.
  2. Key cache operations are logged so when the server fails, the cache can be reconstructed from the log files.
  3. The APIs are similar to Memcached and Redis to reduce cognitive when migrating between platforms.
  4. Since, distcache has pure python implementation the installation process should painless. It's makes it easier to get started up and running.
  5. Its' architecture assumes that the cache clients and servers can fail and plans for it. The impact is minimal on adding and removing cache servers.
  6. Snapshot the servers at regular intervals to avoid cold starts upon crash or planned shutdowns
  7. Log replays also available for slow but complete reconstruction of the cache upon server crash, error or shutdown.
  8. Thread safe increment and decrement operations on keys.
  9. Health of the cache servers is monitored by the client.

Install

pip install distcache

Platform

  • Linux
  • Windows
  • Python 2.7 to Python 3.5

Same Usage Code

Run server.py and client.py on server and client respectively. You can run client.py on as many PCs but remember to ask the server to spawn it once you run client.py. You can run both server and one or more client.py on the same PC. It will create both server and client locally.

client.py

from distcache.cache_client import CacheClient

client = CacheClient()

# Cache operations
client.set("brazil", "football")
client.set("harry", "potter")
client.set(1, 2)
client.set(3, 6)
client.set("hey", "hola")
client.get("hey")
client.get(1)
client.set("hey", "there")
client.get("hey")
client.delete(3)
client.get(3)
client.get("brazil")

server.py

from distcache.cache_server import CacheServer

server = CacheServer('localhost', 2050)

There are more usage codes in the usage directory.

Usage

  • You have multiple servers serving users. And you need to increment user id across the server such that there is no duplicate. Similarly you can store product_id, session_id, user_id, etc.
  • 80% of the database access is generated by 20% of the queries. You should absolutely not be doing duplicate computations. Cache the results. And, the figures vary and you can still use caching service. It just makes things faster.

Contributing

Please read contributing to learn how to contribute to this project.

Release files for distcache 0.1.3.1

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

Source distribution (sdist)

Source distribution for distcache 0.1.3.1
File Size Uploaded
distcache-0.1.3.1.tar.gz 15.4 kB Details

Release files / distcache-0.1.3.1.tar.gz

Download URL distcache-0.1.3.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ecd38552ec7b3642385d3992e4631261143e6142b0d1a2c7cca9cb1d1d4123ad
BLAKE2b-256 checksum
How to use checksums
9cf2a78feaf1d0cff87059eda320e9c84b724ff9a34a99339ab8d4d20782d558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.17

Release history Release notifications | RSS feed

This release

0.1.3.1 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

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