Add a range-binding version of DB template functions.
Partially refactor/de-duplicate existing functions.
Purge media cache images/records after not being used for N days.
N currently defaults to 7.
Purging is currently done at termination, no more than once per day.