add cache truncation (hardcoded at maxlen=1000)