Caching library supporting timeouts, events and external datasources