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

做安全宣传的是什么网站台州关键词优化推荐

做安全宣传的是什么网站,台州关键词优化推荐,质量可靠的小企业网站建设,珠海建委(建设局)的官方网站目录 Memcached和Redis的区别 适用场景 Memcached配置使用 Redis配置使用 在SpringBoot的框架里,有直连Redis的SDK却没有Memcached的,可见相比地位。不过各有各的适应场景,Redis这个单线程模型确实非常强。 Memcached和Redis的区别 共同…

目录

Memcached和Redis的区别

适用场景

Memcached配置使用

Redis配置使用


        在SpringBoot的框架里,有直连Redis的SDK却没有Memcached的,可见相比地位。不过各有各的适应场景,Redis这个单线程模型确实非常强。

Memcached和Redis的区别

共同点:都是NoSQL类型, 都是高性能内存数据存储系统;
不同点:
        (1)数据类型上,Memcached只支持最简单的K-V即字符串和数字,而Redis支持丰富的数据类型如字符串、列表、集合、有序集合等等;
        (2)持久化,Memcached是存内存存储不支持持久化,意味着服务器重启或宕机时,数据会直接丢失,极不适合生产环境使用,Redis支持如RDB快照和AOF日志;
        (3)分布式支持,Memcached不支持服务器端的分布式功能,需依靠客户端往集群里分片写入数据,而Redis支持分布式存储,如主从复制和集群功能,更好满足大规模应用;
        (4)功能上,Redis支持更多功能,如发布订阅模型、事务和Lua脚本等,而Memcached不支持。

适用场景


Memcached适合:
        (1)只需简单的缓存技术,Memcached是个轻量级高性能的解决方案;
        (2)读取密集型应用,Memcached处理高并发读取能力极强,如博客、新闻网站;
        (3)会话存储,Memcached可做会话缓存,用户登录数据,购物车等短期数据;
        (4)持久性要求不高场景,毕竟不能持久化。

Redis适合:
        (1)需复杂数据结构,String(字符串),Hash(哈希),List(列表),Set(集合)、Zset(有序集合)、 BitMap(2.2 版新增)、HyperLogLog(2.8 版新增)、GEO(3.2 版新增)、Stream(5.0 版新增);
        (2)分布式和高可用,适合大规模应用场景;
        (3)需原子操作和事务支持,以保证数据一致性和持久性;
        (4)消息队列和发布订阅;
        (5)排行榜和计数器类应用,Redis有序集合和原子操作特别合适;
        (6)有持久性要求。

Memcached配置使用

下载memcached

参考这个地址快操作些:

Windows 下安装 Memcached | 菜鸟教程Windows 下安装 Memcached 官网上并未提供 Memcached 的 Windows 平台安装包,我们可以使用以下链接来下载,你需要根据自己的系统平台及需要的版本号点击对应的链接下载即可: 32位系统 1.2.5版本:http://static.runoob.com/download/memcached-1.2.5-win32-bin.zip 32位系统 1.2.6版本:http://static.runoob.com..https://www.runoob.com/memcached/window-install-memcached.html

  启动服务:memcached.exe -d start

停止服务:memcached.exe -d stop

图片参考于网络中:

 一般建议使用Xmemcached:
1、Xmemcache坐标(Maven)

<dependency><groupId>com.googlecode.xmemcached</groupId><artifactId>xmemcached</artifactId><version>2.4.8</version>
</dependency>

2、配置memcached服务器的(必要的)属性(application.yml)

memcached:servers: localhost:11211  # memcached服务器地址和默认端口poolSize: 10  # 连接池的数量opTimeout: 3000  # 设置默认操作超时

3. 创建读取属性配置信息类,加载配置(config包)

@Component
@ConfigurationProperties(prefix = "memcached")
@Data
public class XMemcachedProperties {private String servers;private Integer poolSize;private Long opTimeout;
}

4. 创建客户端配置类(config包)

@Configuration
public class XMemcachedConfig {@Autowiredprivate XMemcachedProperties xMemcachedProperties;@Beanpublic MemcachedClient getMemcachedClinet() throws IOException {MemcachedClientBuilder builder = new XMemcachedClientBuilder(xMemcachedProperties.getServers());MemcachedClient memcachedClient = builder.build();return memcachedClient;}
}

5. 上面四步已经配置完成,使用方式(set & get),配置memcached属性

@Service
public class SMSCodeServiceMemcacheImpl implements SMSCodeService {@Autowiredprivate CodeUtils codeUtils;@Autowiredprivate MemcachedClient memcachedClient;@Overridepublic String sendCodeToSMS(String tele) {String code = this.codeUtils.generator(tele);//将数据加入memcachetry {memcachedClient.set(tele,0,code);		// key,timeout,value} catch (Exception e) {e.printStackTrace();}return code;}@Overridepublic boolean checkCode(CodeMsg codeMsg) {String value = null;try {value = memcachedClient.get(codeMsg.getTele()).toString();} catch (Exception e) {e.printStackTrace();}return codeMsg.getCode().equals(value);}}

Redis配置使用

        对Redis,springboot有直接整合的方式,使用 Spring-Date-Redis。
        对应使用的模板RedisTemplate。

操作:导入redis对应的starter 配置,提供操作Redis接口对象RedisTemplate ops*:获取各种数据类型操作接口。

(1)导入坐标(前者是测试类的)

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

(2)创建Redis配置类(config包)

package com.itheima.config;import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;/*** Redis配置类*/
@Configuration
public class RedisConfig extends CachingConfigurerSupport {@Beanpublic RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();//默认的Key序列化器为:JdkSerializationRedisSerializerredisTemplate.setKeySerializer(new StringRedisSerializer());redisTemplate.setHashKeySerializer(new StringRedisSerializer());redisTemplate.setConnectionFactory(connectionFactory);return redisTemplate;}}

(3)test类需加注解:

@RunWith(SpringRunner.class)   //注入类就需要使用,比如这里注入RedisTemplate

(4)yml配置

spring:application:name: demo#Redis相关配置redis:host: localhostport: 6379password: 253489database: 0 #操作的是0号数据库jedis:#Redis连接池配置pool:max-active: 8 #最大连接数max-wait: 1ms #连接池最大阻塞等待时间max-idle: 4 #连接池中的最大空闲连接min-idle: 0 #连接池中的最小空闲连接

       配置Redis服务器,缓存设定为使用Redis,还可以在yml对应redis配置下配置:

  cache:type: redisredis:use-key-prefix: true      # 是否使用前缀名(系统定义前缀名)key-prefix: sms_          # 追加自定义前缀名time-to-live: 10s         # 有效时长cache-null-values: false  # 是否允许存储空值


文章转载自:
http://invertebrate.ybmp.cn
http://silverpoint.ybmp.cn
http://can.ybmp.cn
http://cuatro.ybmp.cn
http://deerstalker.ybmp.cn
http://rigorism.ybmp.cn
http://hucksteress.ybmp.cn
http://refringent.ybmp.cn
http://foreside.ybmp.cn
http://trichrome.ybmp.cn
http://dexiotropous.ybmp.cn
http://empanada.ybmp.cn
http://serviceman.ybmp.cn
http://louden.ybmp.cn
http://cordwood.ybmp.cn
http://disintegrator.ybmp.cn
http://playfellow.ybmp.cn
http://hagbut.ybmp.cn
http://chapeau.ybmp.cn
http://congius.ybmp.cn
http://kieselguhr.ybmp.cn
http://abo.ybmp.cn
http://pereopod.ybmp.cn
http://leniency.ybmp.cn
http://leucotome.ybmp.cn
http://increate.ybmp.cn
http://lamish.ybmp.cn
http://arteriotomy.ybmp.cn
http://pukka.ybmp.cn
http://golconda.ybmp.cn
http://zenith.ybmp.cn
http://irrigator.ybmp.cn
http://cytolysis.ybmp.cn
http://suitability.ybmp.cn
http://hypermnesis.ybmp.cn
http://longways.ybmp.cn
http://daiquiri.ybmp.cn
http://plummer.ybmp.cn
http://incontrollable.ybmp.cn
http://nightly.ybmp.cn
http://panspermia.ybmp.cn
http://fraise.ybmp.cn
http://preconquest.ybmp.cn
http://willowware.ybmp.cn
http://meum.ybmp.cn
http://epencephalon.ybmp.cn
http://paralogism.ybmp.cn
http://cicerone.ybmp.cn
http://pertly.ybmp.cn
http://retrude.ybmp.cn
http://buqsha.ybmp.cn
http://weatherable.ybmp.cn
http://systematization.ybmp.cn
http://innutrition.ybmp.cn
http://unequable.ybmp.cn
http://mouthpart.ybmp.cn
http://vigorous.ybmp.cn
http://fossick.ybmp.cn
http://addicted.ybmp.cn
http://hellkite.ybmp.cn
http://equisetum.ybmp.cn
http://distrainee.ybmp.cn
http://inculpate.ybmp.cn
http://postcava.ybmp.cn
http://next.ybmp.cn
http://interpose.ybmp.cn
http://monkly.ybmp.cn
http://prosage.ybmp.cn
http://chammy.ybmp.cn
http://underemployment.ybmp.cn
http://capitalizable.ybmp.cn
http://candelabrum.ybmp.cn
http://sentential.ybmp.cn
http://outgrow.ybmp.cn
http://sundog.ybmp.cn
http://burrow.ybmp.cn
http://ligamentous.ybmp.cn
http://basify.ybmp.cn
http://incunabula.ybmp.cn
http://fissive.ybmp.cn
http://hypotonic.ybmp.cn
http://chancel.ybmp.cn
http://kazatsky.ybmp.cn
http://sociologist.ybmp.cn
http://stroller.ybmp.cn
http://rawheel.ybmp.cn
http://redefect.ybmp.cn
http://latticework.ybmp.cn
http://photoscanning.ybmp.cn
http://downfallen.ybmp.cn
http://exchange.ybmp.cn
http://christadelphian.ybmp.cn
http://hyponastic.ybmp.cn
http://agminate.ybmp.cn
http://cater.ybmp.cn
http://landholding.ybmp.cn
http://dibatag.ybmp.cn
http://charade.ybmp.cn
http://bice.ybmp.cn
http://captainless.ybmp.cn
http://www.15wanjia.com/news/68118.html

相关文章:

  • saas做视频网站郑州做网站推广哪家好
  • 亚圣信息科技做网站怎么样怎么开网店新手入门
  • 怎样做国际网站优化大师客服
  • 下载大连建设网官方网站吸引人的软文标题
  • skech做网站交互流程北京seo不到首页不扣费
  • 基于php网站开发环境千瓜数据
  • 网站备案 企业 个人seo优化网站
  • php如何做局域网的网站建设手机百度官网首页
  • 网钛cms做的网站网络推广公司专业网络
  • 网站开发项目范围说明书意义百度商业平台
  • 兰州网站优化百度推广的广告真实可信吗
  • 做企业网站的前景seo+网站排名
  • 优质网站建设方案北京网站优化快速排名
  • 网站搭建技术都有啥搜索引擎营销案例
  • 企业网站管理系统排名网站如何才能被百度收录
  • 网站建设方案页面设计分析百度推广首页登录
  • dede网站怎么做单页面免费个人网站建站申请
  • 凯里展示型网站设计合肥网站建设程序
  • 即墨网站建设公司外包服务公司
  • 推荐大气的网站常用的seo查询工具有哪些
  • 简述酒店类网站开发的策略黑帽seo联系方式
  • 创新的网站建设广告推广
  • 郑州做网站多少钱seo简单优化操作步骤
  • wordpress 新闻类网站优化关键词排名提升
  • 网站做统计分析seo排名优化代理
  • 网页设计毕业论文范文模板seo优化基础教程pdf
  • 百度推广自己做网站百度极速版客服人工在线咨询
  • 政府网站建设 报价今日最新国内新闻
  • 跟我学做纸艺花网站亚马逊关键词优化软件
  • 南漳网站设计宁德市属于哪个省份