Cache layer between unserialized data and files


A layer between your unserialized data and the file system.

next is called with (err, data)

  • check cache
    • if nothing's there or if cache is older than the file, load and parse the file, updating the cache
    • otherwise give back the data as you received it

next is called with (err)

  • serialize the data
  • save it to the file
  • update the cache

where parse and serialize are filled in as JSON.parse and JSON.stringify