This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Django Memory Database

What is it?

A library that allows tables to be kept in an in-memory database and optionally can provide persistence between instance restart by spooling the tables to a table that is read upon startup to populate the in-memory tables.

What problem does it solve?

Create in-memory tables with optional data persistence.

How do I install it?

pip install django-memdb

Adding to Django (using integrator)

# At the bottom of your settings.py file.
import django_integrator
django_integrator.add_application('django_memdb')

If you don’t want to use the above, add the application to INSTALLED_APPS and merge the apps settings.py and url.py into the django projects files.

How do I use it?

When defining models, use the class mixin.

For example:

from django.db import models
from django_memdb.mixins import InMemoryDB, PeristentInMemoryDB

class TestModelWithMixin(models.Model, InMemoryDB):
    text = models.TextField()

class TestModelPersistent(models.Model, PeristentInMemoryDB):
    text = models.TextField()

Both mixins work more like a tag, which is used to determine if a table is an in-memory table or not and if the table contents should be stored in the (using the default database) PersistentStorage model.

You can optionally hook into the persistentstorage mechanics by attaching to the signals this app provides. The below example will add compression the data before storing it:

from django_memdb import signals

def compress(arguments):
    "Compress data."
    # pylint: disable=redefined-variable-type
    if arguments['process'] == settings.MEMDB_PROCESS_ENCODE:
        data = arguments['data']
        data = json.dumps(data)
        data = data.encode('utf-8')
        data = zlib.compress(data)
        arguments['data'] = data
    elif arguments['process'] == settings.MEMDB_PROCESS_DECODE:
        data = arguments['data']
        data = zlib.decompress(data)
        data = data.decode('utf-8')
        data = json.loads(data)
        arguments['data'] = data

def callback(sender, **kwargs): # pylint: disable=unused-argument
    "Just insert a hook."
    kwargs['kwargs']['processors'].append(compress)


signals.store_save.connect(callback)
signals.store_load.connect(callback)

Caveat

The in memory database is local to each server instance, thus if you have a setup that uses multiple servers and a single django database instance, you will have synchronisation issues with the in-memory data and hard conflicts when using the persistent storage.

What license is this?

Two-clause BSD

How can I get support?

Please use the repo’s bug tracker to leave behind any questions, feedback, suggestions and comments. I will handle them depending on my time and what looks interesting. If you require guaranteed support please contact me via e-mail so we can discuss appropriate compensation.

Signing Off

Is my work helpful or valuable to you? You can repay me by donating via:

https://paypal.me/MartinHellwig

-or-

https://www.patreon.com/hellwig

Thank you!

Release History

Release History

0.0.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-memdb-0.0.6.tar.gz (9.3 kB) Copy SHA256 Checksum SHA256 Source Sep 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting