Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
goobs-cache
Advanced tools
A versatile caching and state management solution for JavaScript applications. Offers serverless, session, and cookie-based caching with support for encryption, compression, and auto-optimization. Provides a Jotai-like API for seamless integration. Handle
A versatile and efficient caching and state management solution for TypeScript and JavaScript applications. goobs-cache features multiple storage options, encryption, compression, and flexible data management across different environments.
npm install goobs-cache
Or using yarn:
yarn add goobs-cache
Here's a simple example of how to use goobs-cache:
import { serverless, session, cookie, twoLayer } from 'goobs-cache';
// Two-layer caching (automatically syncs between serverless and client-side)
await twoLayer.update('userProfile', 'userStore', { name: 'Alice', age: 28 });
const userProfile = await twoLayer.get('userProfile', 'userStore');
console.log(userProfile); // { name: 'Alice', age: 28 }
// Serverless caching
const serverlessAtom = serverless.atom('serverData', 'dataStore');
await serverlessAtom.set('Hello, Serverless!');
const serverValue = await serverlessAtom.get();
console.log(serverValue); // 'Hello, Serverless!'
// Client-side caching (session storage)
const sessionAtom = session.atom('Hello, Session!');
const [sessionValue, setSessionValue] = session.useAtom(sessionAtom);
console.log(sessionValue); // 'Hello, Session!'
setSessionValue('Updated Session Value');
// Client-side caching (cookies)
const cookieAtom = cookie.atom('cookieData', 'cookieStore');
await cookieAtom.set('Hello, Cookies!');
const cookieValue = await cookieAtom.get();
console.log(cookieValue); // 'Hello, Cookies!'
// Removal
await twoLayer.remove('userProfile', 'userStore');
await serverlessAtom.remove();
await cookieAtom.remove();
// Clearing all caches
await twoLayer.clear();
await serverless.clear();
await cookie.clear();
// Updating configuration
twoLayer.updateConfig();
serverless.updateConfig();
session.updateConfig();
cookie.updateConfig();
goobs-cache offers advanced capabilities for complex use cases:
Configure goobs-cache using a .cache.config.ts
file in your project's root. Here's a comprehensive example:
import { CacheConfig, EvictionPolicy, LogLevel } from 'goobs-cache';
const cacheConfiguration: CacheConfig = {
serverless: {
cacheSize: 10000,
cacheMaxAge: 86400000,
persistenceInterval: 600000,
maxMemoryUsage: 1073741824,
evictionPolicy: 'lru' as EvictionPolicy,
prefetchThreshold: 0.9,
forceReset: false,
compression: {
compressionLevel: -1,
},
encryption: {
algorithm: 'aes-256-gcm',
encryptionPassword: 'your-secure-encryption-password-here-serverless',
keyCheckIntervalMs: 86400000,
keyRotationIntervalMs: 7776000000,
},
},
session: {
cacheSize: 5000,
cacheMaxAge: 1800000,
evictionPolicy: 'lru' as EvictionPolicy,
compression: {
compressionLevel: -1,
},
encryption: {
algorithm: 'aes-256-gcm',
encryptionPassword: 'your-secure-encryption-password-here-session',
keyCheckIntervalMs: 86400000,
keyRotationIntervalMs: 7776000000,
},
},
cookie: {
cacheSize: 1000,
cacheMaxAge: 604800000,
maxCookieSize: 4096,
evictionPolicy: 'lru' as EvictionPolicy,
compression: {
compressionLevel: -1,
},
encryption: {
algorithm: 'aes-256-gcm',
encryptionPassword: 'your-secure-encryption-password-here-cookie',
keyCheckIntervalMs: 86400000,
keyRotationIntervalMs: 7776000000,
},
},
global: {
keySize: 256,
batchSize: 100,
autoTuneInterval: 3600000,
loggingEnabled: true,
logLevel: 'debug' as LogLevel,
logDirectory: 'logs',
},
};
export default cacheConfiguration;
goobs-cache is written in TypeScript and provides comprehensive type definitions for a great developer experience.
goobs-cache is designed for high performance, with features like:
Security is a top priority in goobs-cache:
This project is licensed under the MIT License. See the LICENSE file for details.
goobs-cache is developed and maintained by Matthew Goluba.
For questions or feedback:
Elevate your data management strategy with goobs-cache!
FAQs
A versatile caching and state management solution for JavaScript applications. Offers serverless, session, and cookie-based caching with support for encryption, compression, and auto-optimization. Provides a Jotai-like API for seamless integration. Handle
The npm package goobs-cache receives a total of 30 weekly downloads. As such, goobs-cache popularity was classified as not popular.
We found that goobs-cache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.