Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d202588

Browse files
Update MemcachedConfig.java
1 parent 01b2f0d commit d202588

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/main/java/com/example/devopsapp/config/MemcachedConfig.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.rubyeye.xmemcached.XMemcachedClient;
44
import net.rubyeye.xmemcached.MemcachedClient;
5+
import org.springframework.beans.factory.annotation.Value;
56
import org.springframework.cache.CacheManager;
67
import org.springframework.cache.annotation.EnableCaching;
78
import org.springframework.cache.support.SimpleCacheManager;
@@ -14,9 +15,17 @@
1415
@EnableCaching
1516
public class MemcachedConfig {
1617

18+
// Inject memcached host and port from application.properties
19+
@Value("${memcached.host}")
20+
private String memcachedHost;
21+
22+
@Value("${memcached.port}")
23+
private int memcachedPort;
24+
1725
@Bean
1826
public MemcachedClient memcachedClient() throws IOException {
19-
return new XMemcachedClient("memcached", 11211);
27+
// Use injected host and port instead of hardcoded values
28+
return new XMemcachedClient(memcachedHost, memcachedPort);
2029
}
2130

2231
@Bean

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /