1. duo-cache
The cache duo uses internally
duo-cache
Package: duo-cache
Created by: duojs
Last modified: Thu, 16 Jun 2022 01:45:11 GMT
Version: 2.1.2
License: MIT
Downloads: 41
Repository: https://github.com/duojs/cache

Install

npm install duo-cache
yarn add duo-cache

duo-cache

NPM version
build status

The cache duo uses internally during builds.

API

This cache uses LevelDB
internally (via level).
The idea behind this cache is to help speed up duo's builds by
storing data on disk so it can be read quickly later.

Cache(location)

The location refers to the destination of the LevelDB database directory.

Cache#read()

Reads the all the stored files from the database into memory.

Cache#update(mapping)

Accepts the updated in-memory mapping and saves all the files into cache.

Cache#file(id, [data])

Can be used to set/get a single file's data from the cache. If data is
excluded, it is assumed to be a getter. (otherwise, it will be a setter)

Cache#plugin(name, key, [data])

Can be used to set/get a plugin's cache data. If data is excluded, it
is assumed to be a getter. (otherwise, it will be a setter)

The name should be the same as the plugin's name, to make debugging easier.
The key can be either a String or an Array. Below is a sample plugin
that is using caching.

 // hash the source code as well as options to allow this
// to work even if the user changes their config!
var key = [ hash(src), hash(options) ];

// see if it's already been cached
var cached = yield cache.plugin('plugin', key); // get
if (cached) return cached;

// run the normal transformation
var results = plugin(src, options);
// cache the results for next time
yield cache.plugin('plugin', key, results); // set
return results;

Cache#clean()

Closes the database and wipes it out from the disk.

Roadmap

Currently, this implementation only satisfies the bare-minimum based on
duo's current cache implementation. (currently called the "mapping")

Now that there is a robust data-store in place, more features will be added,
including:

  • give plugins a way to get/set cache data (so they can reduce the amount
    of processing they do on repeated builds)
  • store additional processing during the build process (such as the result
    of scanning a file for dependencies)
  • expose this hook to other modules that cache results (eg: gh-resolve)

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code