Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in-memory DB (lokiJS) vs regular indexedDB

Tags:

I was looking for a wrapper library for indexedDB that can store data.

(Specific use is for a JavaScript cordova app but one that can also work in the browser)

I have found LokiJS which seems feasible. However, LokiJS says it's an:

In-memory JavaScript Datastore with Persistence

But I don't understand what "in-memory" means. I tried googling, looking around, but couldn't find a concise explanation...

How is "in-memory" indexedDB different from regular indexedDB?

like image 799
mesqueeb Avatar asked Mar 19 '19 03:03

mesqueeb


People also ask

Is IndexedDB a memory?

Also, IndexedDB storage in browsers' privacy modes only lasts in-memory until the incognito session is closed (Private Browsing mode for Firefox and Incognito mode for Chrome, but in Firefox this is not implemented yet as of May 2021 so you can't use IndexedDB in Firefox Private Browsing at all).

How fast is IndexedDB?

When you run tests on Nolans Browser Database Comparison you can see that inserting 1k documents into IndexedDB takes about 80 milliseconds, 0.08ms per document. This is not really slow. It is quite fast and it is very unlikely that you want to store that many document at the same time at the client side.


1 Answers

LokiJS is a in-memory DB, which means it will allow you to load, query etc all your data in-memory. Since it is written in Javascript, it will work on multiple environments, inside your browser, inside a NodeJS application, inside a Cordova app etc.

If you are using this inside a Browser application, it can use localstorage or indexedDB to store the data.

If you are using this inside a NodeJS application, it can use the file system or another DB (MySQL, mssql, etc) to store the data.

If you are using this inside a Cordova application, it can use SQLite to store the data.

Basically, depending on where are you running your application and what storage options are available on that platform, it will use that to persist the data.

You can look here to see different adapters available to store data on different platforms-

like image 122
Ali Khalid Avatar answered Sep 16 '22 11:09

Ali Khalid