This allows us to use the $clearCache() method in the following ways:
// clears all CommentsResource entries
CommentsResource.$clearCache()
// clears /?id=68 (2 methods)
CommentsResource.$clearCache({ where: [{ id: 68 }] })
CommentsResource.$clearCache({ where: { id: 68 } })
// clears only /array/?recent=true
CommentsResource.$clearCache({ where: { recent: true }, isArray: true, clearChildren: false })
// clears /array/?recent=true and all entries that belong to the array
CommentsResource.$clearCache({ where: { recent: true }, isArray: true, clearChildren: true })
// clears all CommentsResource entries except for /?id=68 (2 methods)
CommentsResource.$clearCache({ exceptFor: [{ id: 68 }] })
CommentsResource.$clearCache({ exceptFor: { id: 68 } })
// clears all CommentsResource entries except for /array/?recent=true and all entries that belong in which array
CommentsResource.$clearCache({ exceptFor: { recent: true }, isArray: true, clearChildren: false })
// clears all CommentsResource entries except for /array/?recent=true (but still clears all entries which belong in that array)
CommentsResource.$clearCache({ exceptFor: { recent: true }, isArray: true, clearChildren: true })
Tests for where added, tests for exceptFor are still working =)
NOTE This will break existing implementations, because:
BEFORE
// clears all CommentsResource entries except for /?id=68
CommentsResource.$clearCache({ exceptFor: [{ id: 68 }] })
// clears all CommentsResource entries except for /array/?recent=true and all entries that belong to that array
CommentsResource.$clearCache({ exceptFor: { id: 68 } })
AFTER
// clears all CommentsResource entries except for /?id=68 (2 methods)
CommentsResource.$clearCache({ exceptFor: [{ id: 68 }] })
CommentsResource.$clearCache({ exceptFor: { id: 68 } })
// clears all CommentsResource entries except for /array/?recent=true and all entries that belong to that array
CommentsResource.$clearCache({ exceptFor: { recent: true }, isArray: true })
However, we could add a polyfill for old $clearAll() method which would make it working for older implementations also. with a deprecation log message too, ofcourse
This allows us to use the
$clearCache()
method in the following ways:Tests for
where
added, tests forexceptFor
are still working =)NOTE This will break existing implementations, because:
BEFORE
AFTER
However, we could add a polyfill for old
$clearAll()
method which would make it working for older implementations also. with a deprecation log message too, ofcourse