Skip to content
Sajidur edited this page Oct 26, 2024 · 1 revision

FAQ ❓

Welcome to the SnapCache FAQ! Here, we address some frequently asked questions to help you get the most out of SnapCache.

1. What is SnapCache?

SnapCache is a lightweight, in-memory caching tool for Node.js. It provides efficient data retrieval, configurable Time-to-Live (TTL) for cached items, and automatic eviction of old entries, ensuring optimal performance for your applications.

2. How do I install SnapCache?

You can easily install SnapCache using npm. Run the following command in your terminal:

npm install snapcache

3. How do I create a cache instance?

To create a cache instance, require SnapCache and instantiate it with optional configuration parameters like maxSize and defaultTTL. For example:

const SnapCache = require('snapcache');

const cache = new SnapCache({ maxSize: 100, defaultTTL: 30000 }); // Max size 100, default TTL 30 seconds

4. How does TTL (Time-to-Live) work?

TTL determines how long an item remains in the cache before it expires. You can set a TTL for individual items or use a default TTL for all items. Once the TTL expires, the item is removed from the cache.

5. What happens when the cache reaches its maximum size?

When the cache reaches its configured maximum size, SnapCache automatically evicts the oldest item to make space for new entries. This ensures that your cache remains efficient and doesn’t grow indefinitely.

6. Can I manually delete items from the cache?

Yes! You can manually delete specific items from the cache using the delete method. For example:

cache.delete('itemKey'); // Deletes the item with key 'itemKey'

7. How do I clear the entire cache?

To clear all items from the cache, use the clear method:

cache.clear(); // Clears all items in the cache

8. Where can I report bugs or request features?

If you encounter any bugs or would like to suggest a feature, please visit our GitHub Issues page to report them.

9. How can I contribute to SnapCache?

We welcome contributions! Check out our Contributing page for detailed guidelines on how to get involved.

10. Where can I get help or support?

If you have any questions or need assistance, feel free to reach out on our Discord server or create an issue on GitHub.

11. What license is SnapCache under?

SnapCache is licensed under the MIT License. You can find more details in the LICENSE file.