Introduction
Getting started
Welcome to Aggressive Cache, your go-to solution for efficient and robust caching in your web applications.
Installation
Step-by-step guides to setting up your system and installing the library.
Architecture guide
Learn how the internals work and contribute.
Plugins
Extend the library with third-party plugins or write your own.
API reference
Learn to easily customize and modify your app's visual design to fit your brand.
This guide will help you get started with installing dependencies, configuring the library, and using it effectively in your projects. We guarantee that you will be able to get Aggressive Cache set up in your project in under thirty minutes, or your money back!
Installing dependencies
To get started, you need to install the Aggressive Cache library along with its required dependencies. Run the following command in your project directory:
# choose one of the following
npm install @treckstar/aggressivecache --save-dev
yarn add @treckstar/aggressivecache --dev
pnpm add @treckstar/aggressivecache --save-dev
Pitfall! Before you continue...
Ensure you have React and ReactDOM as they are peer dependencies for Aggressive Cache.
Configuring the library
After installation, import and configure Aggressive Cache in your main React file (usually App.js or index.js):
// App.jsx
import React from 'react';
import { CacheProvider } from '@treckstar/aggressivecache';
const App = () => {
return (
<CacheProvider>
{/* Your app components go here */}
</CacheProvider>
);
}
export default App;
Basic usage
Using Aggressive Cache is straightforward. Here's a quick example of caching a component's output:
import { useCache } from '@treckstar/aggressivecache';
const MyComponent = () => {
const { cache } = useCache();
const data = cache.get('myDataKey') || fetchData();
return <div>{data}</div>;
};
export default MyComponent;
Your first cache
To create your first cache, use the set method from the useCache hook:
cache.set('myDataKey', dataToCache);
Clearing the cache
Clearing the cache is just as easy. You can clear a specific key or the entire cache:
// Clear a specific key
cache.clear('myDataKey');
// Clear all cache
cache.clearAll();
Adding middleware
Aggressive Cache supports middleware for advanced caching strategies. Here's how to add one:
import { applyMiddleware } from '@treckstar/aggressivecache';
applyMiddleware(yourMiddlewareFunction);
Getting help
If you need help or have any questions, visit our documentation or reach out to our support team.
Submit an issue
Found a bug or have a feature request? Submit an issue on our GitHub repository.
Join the community
Join our community forum to discuss with other developers and get insights on best practices. Join now.