Make cache db connection thread-safe