-
Notifications
You must be signed in to change notification settings - Fork 1
FAQ
Welcome to the SnapCache FAQ! Here, we address some frequently asked questions to help you get the most out of 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.
You can easily install SnapCache using npm. Run the following command in your terminal:
npm install snapcacheTo 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 secondsTTL 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.
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.
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'To clear all items from the cache, use the clear method:
cache.clear(); // Clears all items in the cacheIf you encounter any bugs or would like to suggest a feature, please visit our GitHub Issues page to report them.
We welcome contributions! Check out our Contributing page for detailed guidelines on how to get involved.
If you have any questions or need assistance, feel free to reach out on our Discord server or create an issue on GitHub.
SnapCache is licensed under the MIT License. You can find more details in the LICENSE file.
📄 License: MIT License
📞 Support: If you have any questions or need assistance, feel free to reach out on our Discord.