Move in-memory caching to separate module
Add sqlite cache implementation