Skip to main content

Distcache is a python open-source distributed in-memory cache and database.

Project description

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.

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

distcache-0.1.3.1.tar.gz (15.4 kB view details)

Uploaded Source

File details

Details for the file distcache-0.1.3.1.tar.gz.

File metadata

  • Download URL: distcache-0.1.3.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for distcache-0.1.3.1.tar.gz
Algorithm Hash digest
SHA256 ecd38552ec7b3642385d3992e4631261143e6142b0d1a2c7cca9cb1d1d4123ad
MD5 718c8ea260cc2f203c715009788cf79b
BLAKE2b-256 9cf2a78feaf1d0cff87059eda320e9c84b724ff9a34a99339ab8d4d20782d558

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