make cache connection thread safe