Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to integrate spring and memcached

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to integrate spring and memcached, with a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

ApplicationContext.xml

Ip and port number

Java class

Package com.bw.memcached;import org.springframework.context.support.ClassPathXmlApplicationContext;import com.danga.MemCached.MemCachedClient;import com.danga.MemCached.SockIOPool;//import com.schooner.MemCached.SchoonerSockIOPool;public class MemcachedTest {public static void main (String [] args) {@ SuppressWarnings ("resource") ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext ("classpath:applicationContext.xml"); context.getBean ("sockIOPool", SockIOPool.class) MemCachedClient client = new MemCachedClient (); / / SockIOPool sockIo = SockIOPool.getInstance (); / / get an initial pool to hold the connection / / String [] as = {"ip: Port number"}; / / declare a string array to hold the connection / / sockIo.setServers (as) / / add all connections to the pool / / sockIo.setInitConn (10); / / set the number of initialized connections / / sockIo.initialize (); / / initialize / / System.out.println ("= initialize connections =" + sockIo.getInitConn ()); client.add ("key", "object") System.out.println (client.get ("key")); / / the above notes are all in the absence of integration with spring}} Thank you for reading this article carefully. I hope the article "how to integrate spring and memcached" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report