Skip to content

Enmap Documentation - Synced to Gitbook

Notifications You must be signed in to change notification settings

soyabn9/enmap-docs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

description
Enmap stands for "Enhanced Map", and is a data structure based on the native JavaScript Map() structure with additional helper methods from the native Array() structure.

What is Enmap?

Enmap stands for "Enhanced Map", and is a data structure based on the native JavaScript Map() structure with additional helper methods from the native Array() structure.

Enmap also offers persistence, which means it will automatically save everything to save to it in a database, in the background, without any additional code or delays.

{% hint style="danger" %} Enmap requires filesystem access. It DOES NOT WORK on Heroku, or other such systems that do not allow you to save data directly to disk. {% endhint %}

Why Enmap?

While there are other better-known systems that offer some features of Enmap, especially caching in memory, Enmap is targetted specifically to newer users of JavaScript that might not want to deal with complicated systems like Redis for caching, or database queries.

Advantage/Disadvantage

Here are some advantages of using Enmap:

  • Simple to Install: Enmap itself only requires a simple npm install command to install and use, and a single line to initialize. When using persistent providers, some additional pre-requisites are necessary. See Installation for details.
  • Simple to Use: Basic enmap usage can be completely done with 1-2 lines of initalization, and 3 commands, set(), get() and delete().
  • Very Fast: Since Enmap resides in memory, accessing its data is blazing fast (as fast as Map() is). Even with persistence, Enmap still only accesses data from memory so you get it almost instantly.

Some disadvantages, compared to using a database connection directly:

  • More memory use: Since Enmap resides in memory and (by default) all its data is loaded when it starts, your entire data resides in RAM. When using a large amount of data on a low-end computer or VPS, this might be an issue for some users.
  • Limited power: You can have multiple Enmap "tables" loaded in your app, but they do not and cannot have relationships between them. Basically, one enmap value can't refer to another value in another enmap. This is something databases can be very good at, but due to the simplistic nature of Enmap, it's not possible here.
  • Lack of scalability: Enmap is great for small apps that require a simple key/value storage. However, a scalable app spread over multiple processes, shards, or clusters, will be severely limited by Enmap as it cannot update itself from the database on change - one process would not be aware of another process' changes.

About

Enmap Documentation - Synced to Gitbook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published