Skip to content

A common component that provides proxy caching mapping. It helps reliably integrate proxy functionality throughout the all involved services.

License

Notifications You must be signed in to change notification settings

mojaloop/inter-scheme-proxy-cache-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@mojaloop/inter-scheme-proxy-cache-lib

inter-scheme-proxy-cache-lib is a common component that provides proxy caching mapping. It helps reliably integrate proxy functionality throughout the all involved services.

CI/CD

This repository uses the mojaloop/build CircleCI orb for standardized CI/CD workflows, including automated Grype vulnerability scanning for source code security.

Use cases:

  • Proxy caching. (see details)
  • Failure count cache with max failure count per {Id}. (see details)

Quick Start

Installation

npm install @mojaloop/inter-scheme-proxy-cache-lib

Basic Usage

// ESM
import { createProxyCache, STORAGE_TYPES } from '@mojaloop/inter-scheme-proxy-cache-lib';
// CJS
const { createProxyCache } = require('@mojaloop/inter-scheme-proxy-cache-lib');

// Redis Cluster
const proxyCacheCluster = createProxyCache(STORAGE_TYPES.redisCluster, {
  cluster: [
    { host: 'localhost', port: 6379 },
    { host: 'localhost', port: 6380 },
    { host: 'localhost', port: 6381 },
  ],
  // Optional: username, password, etc.
});

// Single Redis instance
const proxyCache = createProxyCache(STORAGE_TYPES.redis, {
  host: 'localhost',
  port: 6379,
  // Optional: username, password, db, etc.
});

await proxyCache.connect();

// Basic DFSP to proxy mapping
await proxyCache.addDfspIdToProxyMapping('dfsp_1', 'proxyAB');
const proxyId = await proxyCache.lookupProxyByDfspId('dfsp_1');

API docs

Check IProxyCache interface docs to get more details.

Comprehensive and interactive API documentation, based on TypeScript source code of the package, could be found here

Configuration

Storage Types

The library supports the following storage types:

  • STORAGE_TYPES.redis - Single Redis instance
  • STORAGE_TYPES.redisCluster - Redis cluster configuration
  • STORAGE_TYPES.mysql - MySQL storage (not implemented yet)

Environment Variables

Env Variable Name Default Value Description
PROXY_CACHE_LOG_LEVEL warn The log level for the proxyCache
PROXY_CACHE_DEFAULT_TTL_SEC 20 Default cache TTL for sendToProxiesList keys

Requirements

  • Node.js >= 22.15.0

Development

Build

Command to transpile Typescript into JS:

npm run build

Tests

npm test

Generate Typedoc documentation

npm run docs

Collaborators

About

A common component that provides proxy caching mapping. It helps reliably integrate proxy functionality throughout the all involved services.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 7