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:
- replit@b36030a database.py
- replit@a48d6a2 src/replit/database/default_db.py
- replit@59225fb unit tests
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for betterreplitdb-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2af86396c375ee4c08a1874ec163c0350f05273ea521925fbb7b77ae48f3c2ff |
|
MD5 | acee0d19497c4b59751fbdff4b029ac4 |
|
BLAKE2b-256 | ba5bd76a780d8c8c1e32b14611b118c9210ed95bdb2c679bc1c533b8ff771c8f |