Prefixes - macmcmeans/localDataStorage GitHub Wiki

When on the same domain, prefixes help keep your storage keys from being overwritten by someone else's use of localStorage. Prefixes provide namespacing and let you instantiate more than one copy of localDataStorage using the same keys with each instance, if required.

Prefixes are strongly encouraged but are not mandatory and must be specified when localDataStorage starts up. A period (.) is used to separate the keyname from the prefix, but it may contain periods itself. As with all key names and key values, prefixes are multibyte Unicode‑safe.

EXAMPLES:

Start the software specifying a typical prefix z = localDataStorage( 'mac' ); --> localDataStorage instantiated. Your specified prefix (mac.) adds 4 bytes to every key name (stored using 8 bytes).

Start the software specifying an unconventional prefix z = localDataStorage( '𝘁π”₯π“²π—Œ.π“Ήβ“‘π’†β’‘β“˜π–.π“Ύπ˜΄π–Šπ‘ .𝗹o𝖙𝐬.π‘œπ–‹.π•žβ“”π“‚π”¬π•£π˜†' ); --> localDataStorage instantiated. Your specified prefix (𝘁π”₯π“²π—Œ.π“Ήβ“‘π’†β’‘β“˜π–.π“Ύπ˜΄π–Šπ‘ .𝗹o𝖙𝐬.π‘œπ–‹.π•žβ“”π“‚π”¬π•£π˜†.) adds 103 bytes to every key name (stored using 206 bytes).

Start the software forcing no prefix z = localDataStorage( '' ); --> Empty prefix given (), but a usable prefix is strongly recommended to organize keys! localDataStorage instantiated. Your specified prefix () adds 0 bytes to every key name (stored using 0 bytes).

Start the software getting a random prefix z = localDataStorage(); --> No prefix specified. Creating a random prefix --> 1588540882487:252103633. localDataStorage instantiated. The random prefix (1588540882487:252103633.) adds 24 bytes to every key name (stored using 48 bytes).

When starting localDataStorage, you may also use a few switches.