-
Notifications
You must be signed in to change notification settings - Fork 14
Caching
Arun Prakash edited this page Sep 21, 2025
·
2 revisions
Speed up repeated GET calls with a simple read‑through/write‑through cache.
final client = WordpressClient(
baseUrl: Uri.parse('https://example.com/wp-json/wp/v2'),
bootstrapper: (b) => b
.withCache(
ttl: const Duration(minutes: 5), // default: 1 minute
// cache: MyCustomCacheManager(), // optional custom store
// clearOnWrite: false, // keep cache on POST/PUT/DELETE
)
.build(),
);
- Applies to GET endpoints (list/retrieve/custom GET).
- Default store is in‑memory. Provide your own by implementing
ICacheManager<WordpressRawResponse>
. - After a successful write (POST/PUT/PATCH/DELETE), cache is cleared by default to avoid stale data. Toggle via
clearOnWrite
.
class MyStore implements ICacheManager<WordpressRawResponse> {
// implement put/get/evict/clear as needed
}
Pair caching with the
ParallelWordpress
features for very fast, paginated reads.