sixhours-team / memcached-spring-boot

Library that provides support for auto-configuration of Memcached cache in a Spring Boot application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Query - Override memcached.cache.servers property in code

sandeep540 opened this issue · comments

Need help in overriding the memcached.cache.servers property in Config, Required since I am having servers in 2 cloud locations and want the server list based on proximity

Could you please elaborate what do you mean by overriding the server list i.e. explain your use case a bit more. And if you don't mind could you specify the library & Spring (Boot) version you are using.

Hi @igorbolic

I have a Active-Active DR Setup in Azure where I have 3 memcached servers in Azure-SouthCentral, 3 more in Azure-West , Spring Boot Micro-services run in K8S in both the Regions, these are automatically synced using mcrouter

We have a custom Spring Cloud Config Server which can inject properties based on App and datacenter, (I can have custom properties for different Datacenters)

So, First I want to override the memcached.cache.server properties and read from custom code app config, secondly I will define the order of servers differently for different datacenters, US-SC will have servers in the start and US-West at end, While US-West will have Vice-versa, so that they can read from servers which are near.

I hope, I explained it in detail, Let me know if this helps, else, I will try to get a diagram and share it here

If I've understood your problem correctly, you want to set the server list from the custom code used for application config. This is of course possible, but it not something that library should do for you.
Although it's not exactly the same problem, perhaps take a look here of the approach to update the server list in runtime. I think you could do something similar within your application.

If you wish to update / adjust server list on-the-fly (i.e. override the list form configuration file) you could do it through native client: MemcachedCacheManager#client() from there you could fetch a nativeClient.