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

如何做网站内页排名搜索引擎推广

如何做网站内页排名,搜索引擎推广,柳州网站建设招聘,搭建网站需要多少钱文章目录 一、关于spring-redis二、springboot引入Redis及其使用案例三、封装redistemplate操作工具类 一、关于spring-redis spring-data-redis针对jedis提供了如下功能: 连接池自动管理,提供了一个高度封装的“RedisTemplate”类 针对jedis客户端中大…

文章目录

    • 一、关于spring-redis
    • 二、springboot引入Redis及其使用案例
    • 三、封装redistemplate操作工具类

一、关于spring-redis

spring-data-redis针对jedis提供了如下功能:

  1. 连接池自动管理,提供了一个高度封装的“RedisTemplate”类

  2. 针对jedis客户端中大量api进行了归类封装,将同一类型操作封装为operation接口

    ValueOperations:简单K-V操作
    SetOperations:set类型数据操作
    ZSetOperations:zset类型数据操作
    HashOperations:针对map类型的数据操作
    ListOperations:针对list类型的数据操作

  3. 提供了对key的“bound”(绑定)便捷化操作API,可以通过bound封装指定的key,然后进行一系列的操作而无须“显式”的再次指定Key,即BoundKeyOperations:

    BoundValueOperations
    BoundSetOperations
    BoundListOperations
    BoundSetOperations
    BoundHashOperations

  4. 将事务操作封装,有容器控制。

  5. 针对数据的“序列化/反序列化”,提供了多种可选择策略(RedisSerializer)

    JdkSerializationRedisSerializer:POJO对象的存取场景,使用JDK本身序列化机制,将pojo类通过ObjectInputStream/ObjectOutputStream进行序列化操作,最终redis-server中将存储字节序列。是目前最常用的序列化策略。

    StringRedisSerializer:Key或者value为字符串的场景,根据指定的charset对数据的字节序列编码成string,是“new String(bytes, charset)”和“string.getBytes(charset)”的直接封装。是最轻量级和高效的策略。

    JacksonJsonRedisSerializer:jackson-json工具提供了javabean与json之间的转换能力,可以将pojo实例序列化成json格式存储在redis中,也可以将json格式的数据转换成pojo实例。因为jackson工具在序列化和反序列化时,需要明确指定Class类型,因此此策略封装起来稍微复杂。【需要jackson-mapper-asl工具支持】

    OxmSerializer:提供了将javabean与xml之间的转换能力,目前可用的三方支持包括jaxb,apache-xmlbeans;redis存储的数据将是xml工具。不过使用此策略,编程将会有些难度,而且效率最低;不建议使用。【需要spring-oxm模块的支持】

如果你的数据需要被第三方工具解析,那么数据应该使用StringRedisSerializer而不是JdkSerializationRedisSerializer。

二、springboot引入Redis及其使用案例

springboot引入Redis及其使用案例
参考URL: https://www.cnblogs.com/yuqingya/p/12881712.html

  1. Springboot项目引入依赖

    <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    
  2. 配置

    spring:redis:host: 192.168.10.134port: 6379
    

    spring.redis.host=192.168.10.134
    spring.redis.port=6379
    
  3. 自定义redis配置类

    由于Springboot-data-redis帮我们自动装载了RedisTemplate对象,所以我们无需注册该bean。但是,如果用默认的 RedisTemplate ,那么在序列化存到redis中就会发现,key 就变的“不正常”了。

    比如,存之前key为"test" ,进入redis看,key就变成了"\xac\xed\x00\x05t\x00\x04test" 。这与RedisTemplate默认提供的序列化协议有关。

    @Configuration
    public class RedisConfiguration {@Beanpublic RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();redisTemplate.setConnectionFactory(redisConnectionFactory);// 使用Jackson2JsonRedisSerialize 替换默认序列化Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);ObjectMapper objectMapper = new ObjectMapper();objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);jackson2JsonRedisSerializer.setObjectMapper(objectMapper);// 设置value的序列化规则和 key的序列化规则redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);redisTemplate.setKeySerializer(jackson2JsonRedisSerializer);redisTemplate.afterPropertiesSet();return redisTemplate;}
    }
    
  4. 测试使用
    这里使用SpringRunner.class 是Spring环境进行测试:

    @RunWith(SpringRunner.class)
    @SpringBootTest(classes = EdApplication.class)
    public class FenCiUtilText {@Autowiredprivate RedisTemplate redisTemplate;//测试放入@Testpublic void testRedisSet() {try {redisTemplate.opsForValue().set("test","This is a Springboot-Redis test!");} catch (Exception e){System.out.println(e.toString());}}//测试拿出@Testpublic void testRedisGet() {try {String key="test";Boolean isHas = redisTemplate.hasKey(key);if (isHas){Object test = redisTemplate.opsForValue().get(key);System.out.println(test);}else {System.out.println("抱歉!不存在key值为"+key);}} catch (Exception e){System.out.println(e.toString());}}
    }
    

三、封装redistemplate操作工具类

springboot之使用redistemplate优雅地操作redis
参考URL: https://www.cnblogs.com/superfj/p/9232482.html

@Service
public class RedisService {private static final Logger logger = LoggerFactory.getLogger(RedisService.class);@Autowiredprivate RedisTemplate<String, String> redisTemplate;/*** 默认过期时长,单位:秒*/public static final long DEFAULT_EXPIRE = 60 * 60 * 24;/*** 不设置过期时长*/public static final long NOT_EXPIRE = -1;public boolean set(final String key, String value){boolean result = false;try {ValueOperations operations = redisTemplate.opsForValue();operations.set(key, value);result = true;} catch (Exception e) {logger.error("写入redis缓存失败!错误信息为:" + e.getMessage());}return result;}public boolean set(final String key, String value, Long expire){boolean result = false;try {ValueOperations operations = redisTemplate.opsForValue();operations.set(key, value);redisTemplate.expire(key, expire, TimeUnit.SECONDS);result = true;} catch (Exception e) {logger.error("写入redis缓存(设置expire存活时间)失败!错误信息为:" + e.getMessage());}return result;}public String get(String key) {return key == null ? null : redisTemplate.opsForValue().get(key);}public boolean exists(String key) {return redisTemplate.hasKey(key);}/*** 重名名key,如果newKey已经存在,则newKey的原值被覆盖** @param oldKey* @param newKey*/public void renameKey(String oldKey, String newKey) {redisTemplate.rename(oldKey, newKey);}/*** newKey不存在时才重命名** @param oldKey* @param newKey* @return 修改成功返回true*/public boolean renameKeyNotExist(String oldKey, String newKey) {return redisTemplate.renameIfAbsent(oldKey, newKey);}/*** 删除key** @param key*/public void deleteKey(String key) {redisTemplate.delete(key);}/*** 删除多个key** @param keys*/public void deleteKey(String... keys) {Set<String> kSet = Stream.of(keys).map(k -> k).collect(Collectors.toSet());redisTemplate.delete(kSet);}/*** 删除Key的集合** @param keys*/public void deleteKey(Collection<String> keys) {Set<String> kSet = keys.stream().map(k -> k).collect(Collectors.toSet());redisTemplate.delete(kSet);}/*** 设置key的生命周期** @param key* @param time* @param timeUnit*/public void expireKey(String key, long time, TimeUnit timeUnit) {redisTemplate.expire(key, time, timeUnit);}/*** 指定key在指定的日期过期** @param key* @param date*/public void expireKeyAt(String key, Date date) {redisTemplate.expireAt(key, date);}/*** 查询key的生命周期** @param key* @param timeUnit* @return*/public long getKeyExpire(String key, TimeUnit timeUnit) {return redisTemplate.getExpire(key, timeUnit);}/*** 将key设置为永久有效** @param key*/public void persistKey(String key) {redisTemplate.persist(key);}}

文章转载自:
http://tummler.mdwb.cn
http://tegestology.mdwb.cn
http://pergunnah.mdwb.cn
http://monocarp.mdwb.cn
http://bones.mdwb.cn
http://minesweeping.mdwb.cn
http://derogation.mdwb.cn
http://cloven.mdwb.cn
http://coruscate.mdwb.cn
http://metritis.mdwb.cn
http://trophology.mdwb.cn
http://ironical.mdwb.cn
http://shameful.mdwb.cn
http://carcinoma.mdwb.cn
http://civilize.mdwb.cn
http://revegetation.mdwb.cn
http://heyday.mdwb.cn
http://maharashtrian.mdwb.cn
http://dollarfish.mdwb.cn
http://indulgently.mdwb.cn
http://bilabiate.mdwb.cn
http://accomplish.mdwb.cn
http://melian.mdwb.cn
http://newspaperdom.mdwb.cn
http://uniquely.mdwb.cn
http://fur.mdwb.cn
http://banbury.mdwb.cn
http://skyline.mdwb.cn
http://nwa.mdwb.cn
http://antienvironment.mdwb.cn
http://costful.mdwb.cn
http://pagination.mdwb.cn
http://emanative.mdwb.cn
http://pooch.mdwb.cn
http://fideicommissary.mdwb.cn
http://guadalcanal.mdwb.cn
http://pharynges.mdwb.cn
http://sulphazin.mdwb.cn
http://johnny.mdwb.cn
http://guanine.mdwb.cn
http://slipcase.mdwb.cn
http://shrub.mdwb.cn
http://zygoid.mdwb.cn
http://pragmatise.mdwb.cn
http://quadruplicity.mdwb.cn
http://provokable.mdwb.cn
http://menstruous.mdwb.cn
http://syllabically.mdwb.cn
http://ermentrude.mdwb.cn
http://ndr.mdwb.cn
http://maternity.mdwb.cn
http://disparity.mdwb.cn
http://iddd.mdwb.cn
http://bengaline.mdwb.cn
http://khidmutgar.mdwb.cn
http://vinify.mdwb.cn
http://moneyman.mdwb.cn
http://hypogeusia.mdwb.cn
http://agnomen.mdwb.cn
http://rictus.mdwb.cn
http://boehmenism.mdwb.cn
http://wusuli.mdwb.cn
http://characterological.mdwb.cn
http://arrack.mdwb.cn
http://orthomorphic.mdwb.cn
http://posit.mdwb.cn
http://acheulean.mdwb.cn
http://amphidromia.mdwb.cn
http://eurafrican.mdwb.cn
http://turpeth.mdwb.cn
http://tripoli.mdwb.cn
http://municipalization.mdwb.cn
http://cannister.mdwb.cn
http://remarque.mdwb.cn
http://sari.mdwb.cn
http://discotheque.mdwb.cn
http://lamebrain.mdwb.cn
http://peiping.mdwb.cn
http://tortility.mdwb.cn
http://unhesitatingly.mdwb.cn
http://preemption.mdwb.cn
http://vinton.mdwb.cn
http://cerebric.mdwb.cn
http://achromatism.mdwb.cn
http://impercipience.mdwb.cn
http://foolishly.mdwb.cn
http://germanophile.mdwb.cn
http://gigameter.mdwb.cn
http://antalkaline.mdwb.cn
http://bofors.mdwb.cn
http://flatwoods.mdwb.cn
http://polycentric.mdwb.cn
http://footlights.mdwb.cn
http://rawhead.mdwb.cn
http://wheelwright.mdwb.cn
http://aleut.mdwb.cn
http://scotchwoman.mdwb.cn
http://mingle.mdwb.cn
http://catholyte.mdwb.cn
http://remark.mdwb.cn
http://www.15wanjia.com/news/74346.html

相关文章:

  • 网站建设营销策划方案网络整合营销方案
  • 设置网站字体推广普通话手抄报模板
  • 三水建设局网站网络优化seo是什么工作
  • 网站架构图的制作短视频代运营公司
  • 郑州做网站开发销售网络服务有限公司
  • 做网站如何将一张图片直接变体青岛网站优化公司
  • 网站首页置顶是怎么做市场营销策划案例经典大全
  • wordpress google font 360seo快速排名利器
  • 化妆品网站建设策划方案淘宝怎么推广自己的产品
  • 网站不清理缓存昆明seo网站建设
  • 杭州市富阳区建设局网站免费推广网站大全集合
  • 太原关键词排名首页搜狗网站seo
  • 淄博网站建设团队企业内训课程
  • 福州网站建站外贸营销网站
  • 网站用什么域名外贸网站建设推广公司
  • 阿里云申请域名做网站网站流量数据
  • 推广做网站南充近一周热点新闻
  • 网站备案做网站要转移吗微信推广加人
  • 老年夫妻做爰视频网站成品人和精品人的区别在哪
  • 云服务器 可以做网站吗今日国内新闻头条大事
  • 外贸网站如何优化比较经典的营销案例
  • vi设计作品图苏州网站建设优化
  • 中国供应商网做网站网站怎么优化关键词排名
  • 南宁广告网页设计人才招聘桂平seo关键词优化
  • 支付商城网站制作国内新闻最新
  • wordpress博客增加音乐页面南宁百度推广seo
  • 赣州酒店网站建设长沙优化科技有限公司正规吗
  • 合肥做装修哪个网站好谷歌浏览器app下载安装
  • 网站建设合同补充协议怎么写建立网站的软件
  • 重庆新闻今日最新消息zac seo博客