Setting values
NcachedService.set() writes a value into the cache under one or more keys. The last string key is always the key inside a Map; every key before it acts as a namespace.
Getting values
NcachedService.get() reads a value back out of the cache using the same key path you wrote it under. There's also getOrDefault() for safe access without a try/catch.
Nested namespaces
ng-ncached is called n-cached for a reason: you can nest namespaces as deep as your domain requires. Every key in the path before the last one becomes a namespace; the last key is the entry inside a Map.
TTL & expiration
Every cache entry can carry a time-to-live in milliseconds. When a TTL is set, the entry expires ttl ms after it was written; once expired, get() treats it as missing (and removes it from the underlying Map).
Invalidation
Three methods cover everything from "drop a single entry" to "wipe the world": remove, clear, clearAll. All are no-ops on missing paths — they never throw.
Caching observables
cacheObservable() is the single biggest win for HTTP-heavy apps: one method gives you cache-then-fetch, automatic write-through, request deduplication, optional TTL, and an optional fallback value on error.
Persistence & compression
Persistence makes the cache survive page reloads. It's an opt-in: by default, ng-ncached is purely in-memory.
Configuration
ng-ncached works with zero configuration out of the box — just inject NcachedService. Configuration only kicks in when you want persistence.
Error handling
get(), set() and cacheObservable() throw on failure. Errors are typed classes living under the NcachedServiceErrors namespace, so you can use instanceof to discriminate cases.