Skip to main content

CupidDB cache backend for Django

Project description

Django CupidDB Cache Backend

Django CupidDB Cache is a high-performance caching backend that leverages CupidDB, an in-memory database optimized for speed and efficiency. It supports caching dataframes, dictionaries, lists, and any other data types with low latency and high throughput. Built on Apache Arrow, it ensures fast serialization and retrieval, making it a great choice for any application that needs caching. Give it a try! 🚀

Why Django CupidDB Cache Backend

  • Caching DataFrame has higher performance
  • Cached DataFrame can be filtered and select column, reducing bandwidth and memory usage
  • Additional get_dataframe, keys, and ttl commands in addition to the commands in the default backend
  • Fully tested with Django's cache test suite

Installation

Install with pip

pip install django-cupiddb

Configuration

To start using django-cupiddb, change your Django cache settings to the following example

CACHES = {
    'default': {
        'BACKEND': 'django_cupiddb.cache.CupidDBCache',
        'LOCATION': 'localhost:5995',
        'TIMEOUT': 300,
    },
}

Supports all types of data

Just like all other Django cache backends, CupidDB can handle any type of data that needs to be cached. All views and templates will continue to work as expected.

>>> from django.core.cache import cache
>>> cache.set(key='dict', value={'key': 'value'})
>>> cache.get(key='dict')
{'key': 'value'}

Additional Commands

In addition to the standard cache client methods provided by Django, django-cupiddb also implements the following methods.

Get DataFrame

>>> from django.core.cache import cache
>>> import pandas as pd
>>> from pycupiddb import RowFilter

>>> df = pd.DataFrame({
        'col1': [1, 2, 3, 4, 5],
        'col2': [6, 7, 8, 9, 10],
    })

>>> cache.set(key='df_cache', value=df)

>>> cache.get(key='df_cache')
   col1  col2
0     1     6
1     2     7
2     3     8
3     4     9
4     5    10

>>> filters = [
        RowFilter(column='col2', logic='gte', value=9, data_type='int'),
    ]
>>> cache.get_dataframe(key='df_cache', columns=['col1'], filters=filters)
   col1
0     4
1     5

Key List

>>> cache.keys()
['df_cache', 'dict']

TTL

>>> cache.ttl(key='df_cache')
289.729

# Note: In CupidDB, ttl of 0.0 means the data will persist forever

Warning: Django's cache TIMEOUT settings defaults to 300 seconds and CupidDB backend respects the settings. If you wish to persist your data for longer, you may set the TIMEOUT settings to a larger value or None. Visit Django settings for more details.

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

django_cupiddb-1.4.1.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

django_cupiddb-1.4.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file django_cupiddb-1.4.1.tar.gz.

File metadata

  • Download URL: django_cupiddb-1.4.1.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for django_cupiddb-1.4.1.tar.gz
Algorithm Hash digest
SHA256 00924a93e0e258ece198a4e09f6711d6e2100ece46e5f2aab6fd55290bf108a9
MD5 d8d8b3358791f882bcbcb26e88109459
BLAKE2b-256 1170c45124ad232b076a297fefe1fe9a520e3d7510833cbdbf5f11a812a3e184

See more details on using hashes here.

File details

Details for the file django_cupiddb-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: django_cupiddb-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for django_cupiddb-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3514c8860688e8b54fa5c26775800f3bb74b9efa257013213f900aab357e7f1d
MD5 e1a103de05349d5013f899e87a26b65c
BLAKE2b-256 3dab450897198a68a6e564f11015b61b5304827e7d9f62d85da62a5a62fe8bb8

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