Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Fundamental v1 to v2 Changes

Samuel Voeller edited this page Sep 7, 2021 · 1 revision

Migrating from v1 to v2

Following a chain of additions and new features, underlying functionality was rewritten with k-value. While these changes may not have absolutely constituted a major release on their own, the entirety of the change did meet the criteria of not ensuring integrity for old versions of k-value.

Foundationally, the options used to initialize the Adapters have changed fundamentally for the better. You can look into the changes more in detail on the Examples using and implementing k-value page.

These changed are to allow for easier growth and maintenance going forward, as well as drastic optimization to the code-base for increased speed and precision. The largest additions are:

  • The addition of a new database driver, Knex.js, designed as a batteries-included SQL engine. This allows us to reduce the code needed for each engine and to focus more on the optimizations and less on the per-platform specifics and writing the queries per provider.
  • PostgreSQL has been added as an adapter, as it is native to Knex.js.
  • Single-Layer Caching
    • You can specify { cache: true } in either the Adapter#get() action or globally via the adapter options.
    • This will cache hot-access values in memory to reduce bandwidth and increase the speed at which requests are completed. The downside of this being that you cannot cluster your connection due to potential desynchronization issues.
  • Recursive Object Merging
    • You can specify { merge: true } in the set operation to recursively merge the current and the new value... if both are JSON objects.

The most notable changes are:

  • Optimizations to both MemoryAdapter and the SQL-based adapters to focus on faster read-write operations but also data integrity.
  • Bulk-SQL upsert operations to reduce database overhead and bandwidth.
  • All operations will try to reduce the database overhead by applying from the cache and skipping values that will never return a value from the database.