getCache(key) Method in Merciglobal Cloud ERP¶
The getCache(key)
method is a utility function used to retrieve previously stored values from the server-side or client-side cache in Merciglobal Cloud ERP. Caching is a crucial performance enhancement strategy used across various modules of the ERP system.
Overview¶
getCache(key)
is primarily used for:
- Boosting performance by reducing repeated data fetches
- 📉 Minimizing API/database calls
- 💾 Reusing frequently accessed data
Syntax¶
getCache(key: string): any
- key: A
string
identifier representing the cached object. - Returns: The cached value associated with the key, or
null
if not found.
Use Cases in Merciglobal Cloud ERP¶
- 🔄 Fetching frequently accessed configuration values
- 📊 Retrieving dashboard analytics data
- 📁 Loading master data like currency, country codes, tax rates, etc.
Example¶
const userSettings = getCache('user_settings');
if (userSettings) {
console.log('User settings loaded from cache:', userSettings);
} else {
console.log('No cached data found, fetch from server.');
}
Where is Caching Implemented?¶
In Merciglobal Cloud ERP, caching is intelligently implemented across:
- 🧩 UI Components (e.g., for filters, options)
- 🔐 User sessions
- 🌐 HTTP service wrappers
Cache Expiry & Invalidation¶
Caching in Merciglobal includes TTL (Time to Live) and manual invalidation methods:
clearCache(key)
– to manually remove a specific cache key- Automatic TTL expiry set during
setCache(key, value, ttl)
usage
Best Practices¶
- Always check the cache before API calls to reduce latency
- Use unique and consistent keys to avoid conflicts
- Avoid caching sensitive or frequently changing data
Related Methods¶
Method | Description |
---|---|
setCache(key, value, ttl) |
Stores data in cache with an optional expiration time |
clearCache(key) |
Clears the specific cached key |
hasCache(key) |
Checks if a key exists in cache |
Security Notes¶
- Cached data is accessible only within the user's session scope unless globally stored.
- Never cache passwords, tokens, or PII data.
Benefits in Sales Conversations¶
For the sales team, emphasizing the caching mechanism means:
- Faster UI interactions 🖥️
- Reduced cloud resource usage ☁️
- Better scalability for large enterprises 📊
For more information or technical walkthroughs, please reach out to the Merciglobal Cloud ERP development team or consult the developer hub.