KarelCemus / play-redis

Play framework 2 cache plugin as an adapter to redis-server
Mozilla Public License 2.0
164 stars 44 forks source link

Load Redis configuration at runtime #251

Closed raokrutarth closed 2 years ago

raokrutarth commented 2 years ago

My application does not have the redis connection string available in an env var or in the .conf file. It makes a request at bootstrap to get credentials from a secure service.

Is it possible to initiate the cache with credentials passed at runtime?

e.g. cache: CacheAsyncApi = CacheAsyncApi(host=hostFromSomewhere, port=portFromSomewhere)

KarelCemus commented 2 years ago

You are looking for source: custom . See docs here.

You must use source custom and provide your own implementation of RedisInstance which may freely reuse existing implementations such as Standalone but with customized host and port.

Hope it helps

raokrutarth commented 2 years ago

Is there an example I can look at? I'm trying to understand the code here but not yet sure how to proceed.

Is this what you meant?

raokrutarth commented 2 years ago

Is this still accurate? https://github.com/KarelCemus/play-redis-samples/pull/5/files

KarelCemus commented 2 years ago

Is this still accurate? https://github.com/KarelCemus/play-redis-samples/pull/5/files

Yes, it should be and this is what I meant

raokrutarth commented 2 years ago

Thank you @KarelCemus! Will give these a shot.