Coding task · JavaScript and TypeScript course · Module 9: Design Patterns and Architecture

Exercise: Data Manager

Implement a data manager with an in-memory cache (TTL) and persistent storage in localStorage.

Task

The index.js file has a DataManager class with a Map cache (with a TTL) and storage in localStorage. Fill in the blanks: ___BLANK1___ is the JSON method that turns a value into text before it is stored in localStorage, ___BLANK2___ is the comparison operator that makes get() return the value from the cache only before the expires time, and ___BLANK3___ is the JSON method that turns the text from localStorage back into a value. After an entry expires, get() reads the value from localStorage, for a missing key it returns null, and invalidate removes the key from both places.