当前位置: 首页 > news >正文

佛山医疗网站建设苏州学校网站建设

佛山医疗网站建设,苏州学校网站建设,wordpress怎么调用友情链接,杭州做网站哪家最好【Spring连载】使用Spring Data访问Redis&#xff08;一&#xff09;----快速指南 一、导入依赖二、Hello World程序 一、导入依赖 在pom.xml文件加入如下依赖就可以下载到spring data redis的jar包了&#xff1a; <dependency><groupId>org.springframework.boot…

【Spring连载】使用Spring Data访问Redis(一)----快速指南

  • 一、导入依赖
  • 二、Hello World程序

一、导入依赖

在pom.xml文件加入如下依赖就可以下载到spring data redis的jar包了:

		<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId></dependency>

二、Hello World程序

首先,你需要设置一个正在运行的Redis服务器。Spring Data Redis 需要Redis 2.6或更高版本,并且Spring Data Redis集成了Lettuce和Jedis这两个流行的开源Java库。现在,你可以创建一个简单的Java应用程序,用于向Redis存储和读取值。创建要运行的主应用程序,示例如下:

public class RedisApplication {private static final Log LOG = LogFactory.getLog(RedisApplication.class);public JedisConnectionFactory jedisConnectionFactory() {RedisStandaloneConfiguration redisStandaloneConfiguration =new RedisStandaloneConfiguration();redisStandaloneConfiguration.setHostName("localhost");redisStandaloneConfiguration.setDatabase(0);redisStandaloneConfiguration.setPassword(RedisPassword.of("123456"));redisStandaloneConfiguration.setPort(6379);return new JedisConnectionFactory(redisStandaloneConfiguration);}public static void main(String[] args) {JedisConnectionFactory connectionFactory = new RedisApplication().jedisConnectionFactory();connectionFactory.afterPropertiesSet();RedisTemplate<String, String> template = new RedisTemplate<>();template.setConnectionFactory(connectionFactory);template.setDefaultSerializer(StringRedisSerializer.UTF_8);template.afterPropertiesSet();template.opsForValue().set("foo", "bar");LOG.info("Value at foo:" + template.opsForValue().get("foo"));connectionFactory.destroy();}
}

即使在这个简单的示例中,也有一些值得注意的事情需要指出:

  • 你可以使用RedisConnectionFactory创建RedisTemplate的实例(或ReactiveRedisTemplate,用于响应式使用)。连接工厂是在支持的驱动程序之上的抽象。
  • 没有单一的方法来使用Redis,因为它支持广泛的数据结构,如plain keys(“strings”),lists, sets, sorted sets, streams, hashes等等。
http://www.yayakq.cn/news/199780/

相关文章:

  • 建设厅网站怎么打印不出来wordpress 必备
  • 建设模板网站报价自己怎么建立公司网站
  • 做任务网站源码没有域名可以先做网站吗
  • 网站打不开怎么做wordpress 营销
  • 网站升级改造建设方案网站制作优质公司
  • 宝格丽网站建设策划案网站建设服务器对比
  • 网站如何自己做支付北京软件开发公司排
  • 网站建设宣传语建设厅安全员证
  • 专注高密做网站哪家强怎么投诉没有备案就已经运营网站
  • 爱站工具包官网网站做专题
  • 网站备案怎么转入深圳教育集团网站建设
  • 做一元购物网站中学网站建设方案
  • 个人商城网站备案做微商网站设计
  • 网站设计字体大小规范最精品网站建设
  • 河间网站建设推广企业网站建设维护
  • 淄博网站设上海天华设计有限公司
  • wordpress syntaxhighlighter天津百度seo
  • 公司网站域名cn和com昆明seo网站管理
  • 酒店电子商务网站策划书如何向百度提交自己的网站
  • 网站怎么做接口重庆微信企业网站
  • 上海网站建设咨询站霸网络四川省建设厅官方网站上面查
  • 深圳做网站的公长宁区网站制作
  • vs做网站开发吗wap网站为什么没有了
  • 怎么检查网站的死链注册安全工程师报名时间2022官网
  • 佛山网站设计特色wordpress跳转到微信支付
  • 免费高清图片素材网站推荐建设部住房城乡建设厅网站
  • 注册网站名字网站头图设计
  • 专业网站设计企业互联网行业前沿资讯
  • 做视频的网站wordpress主题评论制作
  • 个人网站备案方法做网站程序