i think i will refactor it into a central function and then do an early return befor the switch in `cache.js`