是否存在仍在活跃维护的NativeScript数据缓存插件?
nativescript-cache) Hey there! I totally get the letdown when a go-to plugin gets abandoned—been there myself. Here are some actively maintained options to fill that caching gap in your NativeScript project:
Recommended Plugins & Tools
@triniwiz/nativescript-cache
This is a maintained fork of the originalnativescript-cacheyou mentioned, so the API is nearly identical (making migration super straightforward). It supports storing all common data types (strings, numbers, objects, arrays) and lets you set custom expiration times for cached items. It’s regularly updated to support the latest NativeScript versions (7+), so compatibility won’t be a headache down the line.nativescript-sqlite
If your caching needs are more complex—like storing structured data, running queries, or handling larger datasets—this actively maintained SQLite plugin is a solid pick. It gives you full control over your cached data with SQL operations, transactions, and persistent storage. Ideal for apps that need more than simple key-value pairs.NativeScript Core’s
ApplicationSettings
While not a dedicated "cache" plugin, the built-inApplicationSettings(part of@nativescript/core) is perfect for lightweight, persistent key-value storage. It’s 100% maintained by the NativeScript team, so it’s rock-solid for storing small bits of data like user preferences, auth tokens, or app state. No extra dependencies needed—just import it and use methods likesetString(),getNumber(), etc.
Quick Usage Example (for @triniwiz/nativescript-cache)
import { Cache } from '@triniwiz/nativescript-cache'; // Store data with a 24-hour expiration Cache.set('user-profile', { name: 'Jane', age: 30 }, 24 * 60 * 60 * 1000); // Retrieve cached data const userProfile = Cache.get('user-profile'); // Clear a specific item or the entire cache Cache.remove('user-profile'); Cache.clear();
Hope these options help you find the right fit for your project!
内容的提问来源于stack exchange,提问作者Jannomeister

