{"id":46041,"library":"react-native-cachemere","title":"React Native Cachemere","description":"An async cache manager for React Native, version 1.2.0. It wraps @react-native-community/async-storage to provide a simple API for caching serializable data with TTL and attempt-based invalidation. The library offers predefined TTL constants (e.g., TTL_12H) and methods like get, set, getAll, clear, clearExpired, and clearByRegex. It is lightweight and focused on React Native, unlike general-purpose cache libraries such as node-cache or lru-cache which are not async or storage-backed. Last updated in 2019; maintenance status is unclear.","status":"deprecated","version":"1.2.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","cache","react-native"],"install":[{"cmd":"npm install react-native-cachemere","lang":"bash","label":"npm"},{"cmd":"yarn add react-native-cachemere","lang":"bash","label":"yarn"},{"cmd":"pnpm add react-native-cachemere","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency as AsyncStorage was removed from React Native core.","package":"@react-native-community/async-storage","optional":false}],"imports":[{"note":"The package uses default export, not named export.","wrong":"import { Cache } from 'react-native-cachemere'","symbol":"Cache","correct":"import Cache from 'react-native-cachemere'"},{"note":"When using CommonJS require, you must access .default because the module uses ESM default export.","wrong":"const Cache = require('react-native-cachemere')","symbol":"default (using require)","correct":"const Cache = require('react-native-cachemere').default"},{"note":"TTL constants are properties of the default exported Cache object, not named exports.","wrong":"import { TTL_12H } from 'react-native-cachemere'","symbol":"TTL constants","correct":"Cache.TTL_12H"}],"quickstart":{"code":"import Cache from 'react-native-cachemere';\nimport AsyncStorage from '@react-native-community/async-storage';\n\n// Initialize (optional if AsyncStorage is already set up)\nconst getData = async () => {\n  const CACHE_KEY = 'my_key';\n  const cached = await Cache.get(CACHE_KEY);\n  if (cached) return cached;\n  \n  const data = await fetch('https://api.example.com/data').then(res => res.json());\n  await Cache.set(CACHE_KEY, data, Cache.TTL_12H, 3);\n  return data;\n};\n\ngetData().then(console.log);","lang":"javascript","description":"Shows basic usage: get cached data, fetch if missing, then cache with TTL and attempt count."},"warnings":[{"fix":"Install @react-native-community/async-storage and link it according to your React Native version.","message":"AsyncStorage has been removed from React Native core since version 0.60. You must install @react-native-community/async-storage separately.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Consider migrating to a maintained alternative like react-native-mmkv or async-storage wrappers.","message":"Package has not been updated since 2019; may have compatibility issues with newer React Native versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure data is JSON-serializable. Use JSON.stringify/parse if needed.","message":"The `data` passed to `set` must be serializable to JSON; objects with functions or circular references will cause errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check for `null` and handle accordingly.","message":"When using `get`, expired cache entries are automatically cleared but the returned value is `null`. Do not confuse with `undefined`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a specific regex to avoid unintended data loss.","message":"The `clearByRegex` method deletes all keys matching the regex unconditionally; there is no confirmation.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'/async-storage':19 '1.2.0':12 '12h':44 '2019':89 'api':24 'async':5,81 'attempt':33 'attempt-bas':32 'back':85 'base':34 'cach':6,26,67,73,77,95 'cachemer':3 'clear':51 'clearbyregex':54 'clearexpir':52 'communiti':18 'constant':41 'data':28 'e.g':42 'focus':59 'general':65 'general-purpos':64 'get':48 'getal':50 'invalid':35 'javascript':94 'last':86 'librari':37,68 'lightweight':57 'like':47 'lru':76 'lru-cach':75 'mainten':90 'manag':7 'method':46 'nativ':2,10,17,62,98 'node':72 'node-cach':71 'offer':38 'predefin':39 'provid':21 'purpos':66 'react':1,9,16,61,97 'react-nat':96 'react-native-commun':15 'serializ':27 'set':49 'simpl':23 'status':91 'storag':84 'storage-back':83 'ttl':30,40,43 'unclear':93 'unlik':63 'updat':87 'version':11 'wrap':14","created_at":"2026-06-07T12:57:59.641684+00:00","updated_at":"2026-06-07T12:57:59.641684+00:00","problems":[{"fix":"npm install @react-native-community/async-storage","cause":"Missing peer dependency.","error":"Cannot find module '@react-native-community/async-storage'"},{"fix":"import Cache from 'react-native-cachemere' (without curly braces)","cause":"Using named import instead of default import.","error":"Cache.get is not a function"},{"fix":"Ensure data is a plain serializable object.","cause":"Data passed to `set` is not an array or object but an iterable?","error":"TypeError: Invalid attempt to spread non-iterable instance"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"react-native-cachemere","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}