replit-chunk-store

1.0.0 • Public • Published

replit-chunk-store

Replit Database chunk store that is abstract-chunk-store compliant

abstract chunk store

Apparently, Replit just allows you to store Buffers in their key-value database, so let's use it to overcome replspace filesystem limitations! Of course, Replit DB does seem to have some limitaitons, but the ones given don't seem to apply anymore, as I've stored far more than 50 MB using this module. Infinite storage glitch, anyone?

Docs

const ReplitStorage = require("replit-chunk-store")
const store = new ReplitStorage(1024)

This implements the abstract-chunk-store interface quite nicely, as it's heavily based off of memory-chunk-store. There's only one difference between using this chunk store and any other: the constructor's opts parameter takes one extra key, key, which allows one to specify the database URL they want to use instead of process.env.REPLIT_DB_URL.

const store = new ReplitStorage(1024, {key: "https://my-repl-db.example.com/"})
// passed as: new Client(opts.key)

If you want to want to access the underlying client, use store.client. Just make sure you haven't destroyed the store before doing so, as I set client to null so that it's garbage-collected.

Man, do I love abstractions and interfaces!

Why?

My recent project webtorrent-server makes use of WebTorrent, which itself uses abstract-chunk-store to store pieces. I was running into issues with running out of space on disk in replspace since WebTorrent in Node.js uses fs-chunk-store by default and the stuff I was torrenting was large. Using memory-chunk-store wasn't cutting it either due to repls having very little RAM. I then rememebered that Replit comes with a database, and here we are.

Package Sidebar

Install

npm i replit-chunk-store

Weekly Downloads

0

Version

1.0.0

License

Unlicense

Unpacked Size

6.9 kB

Total Files

5

Last publish

Collaborators

  • supersonichub1