S
S
Sergey Sokolov2019-02-07 22:38:53
JavaScript
Sergey Sokolov, 2019-02-07 22:38:53

What is the best way to store an array of integers in IndexedDB: TypedArray or ArrayBuffer?

The task is to save lists of 32-bit unsigned integers (~1e7 values) in the user's browser.
They do not need to be searched, they are not indexed. Indexes are different - timestamp and all sorts of id.
I see three options:

  1. data: [1,2,3]- regular array
  2. data: new Uint32Array([1,2,3])- typed array
  3. data: new Uint32Array([1,2,3]).buffer– ArrayBuffer.

Are there any fundamental differences with the so-called. occupied disk space and write / read speed? It will also be used on mobile devices.
I looked with FireFox devtools (Storage tab) - in the first two, the recorded values ​​\u200b\u200bare visible, and for ArrayBuffer it shows as a black box {}. And for TypedArray, it seems like it appends a key to each value. I use Dexie
to work with IndexedDB .

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question