Skip to main content

Replit DB with a memcache

Project description

Better Replit DB (Python)

Adds a memcache to the standard replit database

To perform database operations such as reading, writing and deleting data, the official replit package simply sends the corresponding request to your REPL's database URL. However, this can be made more efficient by caching the database in RAM using a python dictionary, initialized when the database is created/when the REPL starts. For AsyncDatabase, read operations read from the cache and update/delete operations will update the cache, then perform the action asynchronously as before. The same occurs for the synchronous Database but with regular/synchronous update operations.

Usage

Async:

Replace

from replit.database import AsyncDatabase

async_db = AsyncDatabase(replit_db_url)

with

from betterreplitdb import AsyncDatabase

async_db = AsyncDatabase(replit_db_url)
async_db.init_cache()

Note: Replit's docs say that you need to use AsyncDatabase() to construct a DB. This is false, please use AsyncDatabase(environ["REPLIT_DB_URL"]) instead, where environ is os.environ.

Sync:

Replace

from replit import db

with

from betterreplitdb import db

Version Tracking

This repo is up to date with the main repo with commits:

If these are not the latest commits on these files, please open an issue/PR.

Copyright

This repo is forked from Replit's, which is licensed under the ISC license, as is this project.

Copyright disclaimer for replit/replit-py

Copyright 2021 Replit

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

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

betterreplitdb-0.0.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

betterreplitdb-0.0.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file betterreplitdb-0.0.3.tar.gz.

File metadata

  • Download URL: betterreplitdb-0.0.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for betterreplitdb-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b21e827e0800b173b835fadcd33634000732dc000398ec342d114fde62a8e2be
MD5 10e417d477ed71d91d6850fabf4384f0
BLAKE2b-256 61bf2b6f0ea2875a75273ad75518fa5451c93b6f785fa590ef8ecd73be83569b

See more details on using hashes here.

File details

Details for the file betterreplitdb-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: betterreplitdb-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for betterreplitdb-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 81d722b7fffb8d760b79f9d4f12237aa40714e24c8485c27c12f53b9951c6ce1
MD5 ff8fedb29c93313522e0ea201abdbc25
BLAKE2b-256 346f50f93ed50cbc65a4d8a2b58d1e09a9f8736fe180e721826f53f3434534be

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