
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
mcode-cache
Advanced tools
Our Data Caching functions. These support files, JSON, JS Objects, any primitive, etc. And provide common keying support.
A public NPM Package of our internal data caching tools for Frontend and Backend JavaScript NodeJS projects.
This is an extremely 'light weight' package with dependencies on our internal 'data' and 'log' packages and on node-cache and Redis for an optional caches.
This is our own internal data caching code for common operations like caching files contents, data structures, lists (for out mcode-list processing), and automatic key creation and standardization.
> node examples


When using data caching it's best to start with a good definition of the objects your App will cache and why.
USE CASE #1: Files, for speed. When a Web App frequently goes to disk, HDD or SSD, to serve clients
there is inherent latency. Automatically caching these frequenlty used files in RAM and serving them from there is typically 10X faster.
Normal, uncached code retrieving a file...
const iconContent = await fs.readFile(iconPath, 'utf8');
-----------
To cache for repeated usage with our package, just change "fs.readFile()" to "mcode.fileRead()"...
const iconContent = await mcode.fileRead(iconPath, 'utf8');
--------------
...this does four (4) things within one line change:
USE CASE #2: Context, for speed. When building a rich App a large part of the UX is context, the feeling that the App knows (and remembers) what you are doing. This is held in two forms of memory analogous tohuman 'short term' and 'long term' memory...
Both of these shoudl be cached, with different Time-To-Live (TTL), and different invalidation schemes.
This is all handling in a standard way in our package, for our App designs.
USE CASE #3: Database, for speed. Because anything you can retrieve from RAM instead of the disk based DB
will be at 10X to 50X faster.
npm install mcode-cache
This package includes a simple demo module: examples.js. Running it directly will show you a set of examples for using fileRead() and fileChange().
node .\node_modules\mcode-cache\examples
...this will demonstrate thru console logging various uses of the mcode-cache functions.
npm install --save-dev jest
npm test




These are the functions we want at the ready in any module for development and debug.
| Function | Description | Usage |
|---|---|---|
| General | ||
| addNamespace | Creates a new Namespace--in Node or Redis--for caching or accessing data. | mcode.addNamespace(({name: 'MicroCODE', type: 'node'}) |
| cacheGet | Gets the value of a Key from the Cache, from App's namespace. | value = mcode.cacheGet(key, defaultCallback) |
| cacheSet | Sets the value of a Key from the Cache, in App's namespace. | mcode.cacheSet(key, value) |
| cacheDrop | Drops a key from the Cache. | count = mcode.cacheDrop(key) |
| cacheDropAll | Drops all keys from a namespace in the Cache, defaults to current. | count = mcode.cacheDropAll({cache: 'redis', namespace: 'GM-GPS-eMITS-DB', pattern: '*'}) |
| cacheListAll | Lists all keys from a namespace in the Cache, defaults to current. | array = mcode.cacheListAll({cache: 'node', namespace: '', pattern: ''}) |
| cacheMakeKey | Generates a well formatted Cache Key form a resource key. | key = mcode.cacheMakeKey(key) |
| cacheOn | Turns the caching of Node data ON. (The default state). | void mcode.cacheOn(cacheName) |
| cacheOff | Turns the caching of Node data OFF. (For active development). | void mcode.cacheOff(cacheName) |
| redisOn | Turns the caching of Redis data ON. (The default state). | DEPRECATED in v0.8.0 |
| redisOff | Turns the caching of Redis data OFF. (For active development). | DEPRECATED in v0.8.0 |
| cacheClose | Closes the Node and Redis caches, and the connection to the Redis Server. | void mcode.cacheClose(path) |
| File Specific | These directly replace "fs" file operations | |
| fileRead | Reads a file from storage with a standard 'path' and caches it. | contents = mcode.fileRead(path, encoding) |
| fileWrite | Writes a file to storage with a standard 'path' and caches it. | state = mcode.writeRead(path, contents, encoding) |
| fileDrop | Invalidates a standard 'path', forcing a fresh read/cache on next access. | count = mcode.fileDrop(path) |
| fileMakeKey | Generates a well formatted Cache Key from a standard file path. | key = mcode.fileMakeKey(path) |
| fileGetRoot | Gets the root directory for Cache Keys based on app's execution path. | path = mcode.fileGetRoot(path) |
These are the properties for interacting with the mcode-cache instance.
| Property | Description | Usage |
|---|---|---|
| cacheNamespaces | The active namespaces and their types (Node or Redis). | const namespaces = await mcode.cacheNamespaces; |
| cacheReady | The Cache is ready for use, Redis online, Namespace is established. | if (mcode.cacheReady) |
| cacheTTL | The current Time-To-Live, the expiration in milliseconds of current tags. | mcode.cacheTTL = 30000 |
| redisURL | The network address of the Redis Server, 'redis://:. | mcode.redisURL = 'redis://127.0.0.1:6379' |
| cacheNamespace | The namespace for all tags until changed, defaults to 'MicroCODE'. | mcode.cacheNamespace = 'MyAppName' |
| cacheEnabled | The current state of Node namespace caching, True = Caching is ON. | if (mcode.cacheEnabled(cacheName)) |
| redisEnabled | The current state of Redis namespace caching, True = Caching is ON. | DEPRECATED in v0.8.0 |
We believe is explicit code documentation, for other users, and for our 'future selves'.
JSDocs is a standardized system for documenting functions and data structures that produces three (3) primary outputs:
This entire project--like all our projects--is documented with JSDocs.
To install JSDocs use, get to a terminal session in the project folder...
npm install --save-dev jsdoc
jsdoc.json
jsdoc -c .jsdoc.json
...then open ./docs/index.html

Contact Timothy McGuire, support@mcode.com.
| Word or Acronym | Description/Definition |
|---|---|
| NPM | Node Package Manager, actually “Node PM”, “Node pkgmakeinst” a system to deploy, install, and maintain NodeJS Apps. (PM was a BASH utility). |
| NVM | Node Version Manager, a tool that supports changing NodeJS versions. |
| MERN | MongoDB, Express, React, Node JS. |
| MongoDB | A ‘NoSQL’ database designed for Cloud applications, also referred to as a ‘Document Store’. |
| Express | Express is not a database but rather an ‘extensible routing language’ for communication between a Client and a Server. |
| React | A Web UI development system, a JavaScript library developed by Facebook and made public—and Open Source—since 2013. |
| Redis | A Remote Dictionary Server, a standard through the web development industry. |
| node-cache | The Node.js Cache for 'in app' caching on the App's own server. |
| Node.js | A development stack that executes from a local file store—on a local Server—instead of from a network of servers. |
| JSDocs | A toolset to automatically generate API-style documentation from source code tagging. |
Contributor's names and contact info...
0.8.1
0.8.0
v0.7.1
v0.7.0
v0.6.10
v0.6.9
v0.6.8
v0.6.7
v0.6.6
v0.6.5
v0.6.4
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.5
v0.5.4
v0.5.3
v0.5.0 - 0.5.2
v0.4.0
v0.0.5
v0.0.4
v0.0.3
v0.0.2
v0.0.1
This project is licensed under the MIT License - see the LICENSE.md file for details
MicroCODE, Inc. was founded in 1987 as a controls engineering and software development company.
We specialize in manufacturing and quality control applications that must run 24x7x365 for years at a time.
Our slogan, distilled from over three decades of developing, testing, installing, and supporting 24x7x365 manufacturing applications, is..

FAQs
Our Data Caching functions. These support files, JSON, JS Objects, any primitive, etc. And provide common keying support.
We found that mcode-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.