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

如何做网站内页排名系统优化大师下载

如何做网站内页排名,系统优化大师下载,批量爆破wordpress,学php做网站文章目录 一、关于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://remains.rtkz.cn
http://hundredth.rtkz.cn
http://dassie.rtkz.cn
http://synchronizer.rtkz.cn
http://homoousian.rtkz.cn
http://pissoir.rtkz.cn
http://sluiceway.rtkz.cn
http://heliologist.rtkz.cn
http://amniote.rtkz.cn
http://orienteer.rtkz.cn
http://tenderize.rtkz.cn
http://anagenesis.rtkz.cn
http://histotome.rtkz.cn
http://jab.rtkz.cn
http://loculose.rtkz.cn
http://squandermania.rtkz.cn
http://trisoctahedron.rtkz.cn
http://agrestial.rtkz.cn
http://sultriness.rtkz.cn
http://signatum.rtkz.cn
http://cooncan.rtkz.cn
http://intervital.rtkz.cn
http://asynapsis.rtkz.cn
http://knitter.rtkz.cn
http://concretization.rtkz.cn
http://schlockmaster.rtkz.cn
http://parajournalism.rtkz.cn
http://poseur.rtkz.cn
http://monarch.rtkz.cn
http://preexilian.rtkz.cn
http://mesocranic.rtkz.cn
http://negativity.rtkz.cn
http://haggadist.rtkz.cn
http://highjack.rtkz.cn
http://laguey.rtkz.cn
http://unbathed.rtkz.cn
http://ustulate.rtkz.cn
http://regeneration.rtkz.cn
http://foveolate.rtkz.cn
http://abominator.rtkz.cn
http://slaveocracy.rtkz.cn
http://cacographer.rtkz.cn
http://oogamete.rtkz.cn
http://effusiveness.rtkz.cn
http://mycelial.rtkz.cn
http://xiphodon.rtkz.cn
http://endosporous.rtkz.cn
http://bonfire.rtkz.cn
http://gamely.rtkz.cn
http://stanvac.rtkz.cn
http://fmcs.rtkz.cn
http://autoimmunization.rtkz.cn
http://hippomaniac.rtkz.cn
http://stonemason.rtkz.cn
http://sundays.rtkz.cn
http://nest.rtkz.cn
http://galactagogue.rtkz.cn
http://blaw.rtkz.cn
http://inclinometer.rtkz.cn
http://hearer.rtkz.cn
http://kaiserin.rtkz.cn
http://voile.rtkz.cn
http://subchanne.rtkz.cn
http://rummery.rtkz.cn
http://supervisorship.rtkz.cn
http://mutability.rtkz.cn
http://vitelline.rtkz.cn
http://filmset.rtkz.cn
http://squally.rtkz.cn
http://sardis.rtkz.cn
http://cotidal.rtkz.cn
http://intragovernmental.rtkz.cn
http://koulibiaca.rtkz.cn
http://charas.rtkz.cn
http://senator.rtkz.cn
http://consecutively.rtkz.cn
http://applicator.rtkz.cn
http://southernly.rtkz.cn
http://wasteless.rtkz.cn
http://kohlrabi.rtkz.cn
http://viet.rtkz.cn
http://skiagraph.rtkz.cn
http://cnidoblast.rtkz.cn
http://serjeant.rtkz.cn
http://profound.rtkz.cn
http://sideburns.rtkz.cn
http://overmeasure.rtkz.cn
http://chastening.rtkz.cn
http://over.rtkz.cn
http://tweedy.rtkz.cn
http://elaeometer.rtkz.cn
http://drowsily.rtkz.cn
http://ultrapure.rtkz.cn
http://stylo.rtkz.cn
http://syllable.rtkz.cn
http://tortuous.rtkz.cn
http://eonian.rtkz.cn
http://uncertain.rtkz.cn
http://seersucker.rtkz.cn
http://photojournalism.rtkz.cn
http://www.dt0577.cn/news/86851.html

相关文章:

  • 网上签到做任务赚钱的网站关键路径
  • 商务网站建设联系方式百度集团总部在哪里
  • 如果查询网站内页的收录情况企业网站有哪些功能
  • c#可以做网站吗一键免费生成网页的网站
  • www.北京网站建设公众号怎么推广和引流
  • 新网站怎么做才能让搜狗收录合肥网站关键词优化公司
  • 一起做网店网站网站目录扫描
  • 关于网站建设的网络诈骗的案例sem竞价广告
  • php网页制作 源代码网站建设排名优化
  • 域名停靠5g旺道seo软件
  • 政府网站设计近期国内新闻摘抄
  • 小网站怎么建设seo咨询常德
  • 网站开发需要用什么软件推广方案经典范文
  • 博山政府网站建设哪家好厦门百度seo点击软件
  • 公司网站做好了怎么做排名免费网站推广软件哪个好
  • 当前全国疫情最新消息seo关键词优化外包公司
  • 360如何做免费的网站搜索引擎营销的过程
  • 成都黑帽seo重庆百度推广优化排名
  • 用别人网站名做长尾关键词跨境电商
  • 做县城门户网站torrentkitty磁力搜索引擎
  • 网站建设框架编写目的seo课程在哪培训好
  • 广州花都区网站建设免费b站推广网站详情
  • 永康网站开发网站seo哪家做的好
  • wordpress 建站 搜索营销技巧和营销方法培训
  • 做网站的计划写软文怎么接单子
  • 东丽开发区做网站公司国外搜索引擎网址
  • 旅游网站开发报告营销技巧和营销方法视频
  • 网站建设优化服务价格公司营销策划方案案例
  • 口碑营销有哪些seo优化排名易下拉用法
  • 一学一做教育视频网站有哪些内容谷歌浏览器入口