PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] How to Configure Spring Boot with Memcached

 November 12, 2022     caching, java, memcached, spring-boot     No comments   

Issue

I am new to Memcached. I need to configure my spring boot application with Memcached.

I researched a lot on the topic but I could not find a documentation for the same. By default Spring boot uses Concurrent HashMap for caching but how do I configure Memcached.

I got this GitHub URL but I am not sure if this is the correct way and if so how do I use the same.

https://github.com/sixhours-team/memcached-spring-boot

https://www.javacodegeeks.com/2013/06/simple-spring-memcached-spring-caching-abstraction-and-memcached.html

Update

I have used this in my project now https://github.com/bmatthews68/memcached-spring-boot-starter.

Like this

@Override @Cacheable(value = "defaultCache")
    public String customMethof() throws InterruptedException {
        return "Testing";
    }

but when i do a telnet of get defaultCache i get nothing Please help


Solution

Add this to your Gradle Dependencies

compile group: 'net.spy', name: 'spymemcached', version: '2.12.3'
compile('com.btmatthews.springboot:memcached-spring-boot-starter:1.0.0')

On top of your main Spring boot application where you @SpringBootApplicationthis annotation put this

@EnableMemcached

Then in your Component use the following

@Autowired
private MemcachedClient memcachedClient;

memcachedClient.get("...")


Answered By - Rahul Singh
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing