Skip to content

Implement simple sync/async key value storage interface with version support #2

Description

@jhnns

The web offers some simple key-value storage interfaces, such as localStorage, sessionStorage, or adapters for indexedDB.

However, using these storage options can cause a few problems in large applications or over a longer period of time:

  • Keys can overlap (no warning if two code locations use the same key)
  • Migration is not taken into account: how to deal with it if a different/new data format is needed
  • If the logout process takes a little longer, it can happen that data is still written even after logging out and thus continues to exist after logging out
  • Serializing and deserializing might not be loss-less, e.g. undefined with JSON.stringify

The implementation should:

  • Provide some kind of registry that prevents multiple code locations using the same key
  • Work with version numbers immediately so that simple migrations can be written
  • Offer a kind of kill switch (e.g., a drop() method) after which it is no longer possible to write to storage
  • Offer a custom strategy for JSON.parse

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions