Make Replit DB 30x-50x Faster on Nodejs with just One Line
The Line Change:
Replace require('@replit/database')
with require('better-replit-db')
in your JS file.
How/Why it Works
I recently decided to fork the Replit DB client to add a feature which I thought would greatly improve it: a memcache.
The idea is that instead of every read and write being a get/post request to the actual database, everything is done through a dictionary stored in ram. To then make sure data persists, every write also writes to the DB, but asynchronously. This allows for the program to continue on without having to wait for the request to resolve, therefore increasing speed.
Don't believe me that this helps? Check out these speed results: (20 Operations of Each)
Any recommendations for what I should add, let me know!
P.S. I plan on adding the same feature set to forks of other Replit DB libraries.
nice
perhaps do this in python too?
The .NET languages (C#, F#, VB) at any [email protected]
class Program{ static void Main(string[]args){ System.Console.WriteLine("I hope."); } }
oh hi piero
This is a great idea. I think this would be especially useful in applications that need to write data that must be read immediately - such as shared data, reducing the error rate.
Fantastic! Repl db always was a bit slow so it’s great to see speed increases.
Great job!
Every time I start my program, the data goes null.
After restarting and removing the set function: