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

网站建设过程小结wordpress页面设计外贸

网站建设过程小结,wordpress页面设计外贸,微信小程序开发教程视频,邢台企业做网站一、redis介绍 简介 Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库。 Redis 与其他 key - value 缓存产品有以下三个特点: Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可…

一、redis介绍

  • 简介

Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库。

Redis 与其他 key - value 缓存产品有以下三个特点:

  • Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。
  • Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。
  • Redis支持数据的备份,即master-slave模式的数据备份。
  • 优势

  • 性能极高 – Redis能读的速度是110000次/s,写的速度是81000次/s 。
  • 丰富的数据类型 – Redis支持二进制案例的 Strings, Lists, Hashes, Sets 及 Ordered Sets 数据类型操作。
  • 原子 – Redis的所有操作都是原子性的,意思就是要么成功执行要么失败完全不执行。单个操作是原子性的。多个操作也支持事务,即原子性,通过MULTI和EXEC指令包起来。
  • 丰富的特性 – Redis还支持 publish/subscribe, 通知, key 过期等等特性。

二、redis服务启动

  • windows下安装

下载地址:https://github.com/tporadowski/redis/releases。

Redis 支持 32 位和 64 位。这个需要根据你系统平台的实际情况选择,这里我们下载 Redis-x64-xxx.zip压缩包到 C 盘,解压后,将文件夹重新命名为 redis

开两个cmd窗口,一个启动redis-server.exe,一个启动redis-cli.exe

  • linux下安装

指导链接:Redis 安装 | 菜鸟教程 (runoob.com)

三、java 中使用redis

  • pom.xml引入
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>org.apache.commons</groupId><artifactId>commons-pool2</artifactId>
</dependency>
<dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId>
</dependency>
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>2.0.32</version>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
  • properties配置
// 当前为spring 2.x.x版本下配置
spring.datasource.redis.database=0   
spring.datasource.redis.host=127.0.0.1   //redis服务器ip
spring.datasource.redis.password=        //密码为配置的redis权限密码
spring.datasource.redis.port=6379 // sping 3.x.x版本下配置 
# Redis 数据库索引(默认为0)
spring.data.redis.database=0
# Redis 服务的ip,我的是在虚拟机的服务器上。
spring.data.redis.host=192.168.45.129
# Redis 端口
spring.data.redis.port=6379
# Redis 密码,默认为空,可以修改 redis.conf配置文件
spring.data.redis.password=
# 最大可用连接数
spring.redis.pool.max-active=200
# 从连接池中获取连接最大等待时间
spring.redis.pool.max-wait=-1
# 最大空闲连接数
spring.redis.pool.max-idle=10
# 最小空闲连接数
spring.redis.pool.min-idle=0
# redis连接超时时间(单位为毫秒)
spring.data.redis.timeout=1000
  • bean创建
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;@Configuration
public class RedisConfig {/*** 连接工厂*/@Bean//读取配置文件中redis的配置@ConfigurationProperties(prefix = "spring.datasource.redis")public JedisConnectionFactory jedisConnectionFactory() {JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();jedisConnectionFactory.afterPropertiesSet();return jedisConnectionFactory;}/*** RedisTemplate* @param redisConnectionFactory redis连结* @return RedisTemplate*/@Bean@ConditionalOnMissingBean(name = "redisTemplate")public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {//StringStringRedisSerializer stringRedisSerializer = new StringRedisSerializer();ObjectMapper om = new ObjectMapper();//PropertyAccessor.ALL:所有;JsonAutoDetect.Visibility.ANY修饰范围:ANY-所有om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);//指定序列化输入的类型,类必须是非final修饰的om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);jackson2JsonRedisSerializer.setObjectMapper(om);RedisTemplate<String, Object> template = new RedisTemplate<>();//连接工厂template.setConnectionFactory(redisConnectionFactory);//全局key的序列化策略template.setKeySerializer(stringRedisSerializer);//全局value的序列化策略template.setValueSerializer(jackson2JsonRedisSerializer);//全局HashKey的序列化策略template.setHashKeySerializer(stringRedisSerializer);//全局HashValue的序列化策略template.setHashValueSerializer(jackson2JsonRedisSerializer);//支持事务template.setEnableTransactionSupport(true);template.afterPropertiesSet();return template;}
}
  • 工具类封装
// 示例,具体使用依照自身业务情况而定import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;@Component
public class RedisUtil {@Autowiredprivate RedisTemplate<String, Object> redisTemplate;public String getString(String key) {Object value = redisTemplate.opsForValue().get(key);System.out.println(value);return value == null ? null : value.toString();}public void setValue(String key, Object value) {redisTemplate.opsForValue().set(key, value);}}

四、redis常见指令

  • 【redis-cli --raw】客户端启动避免中文乱码
  • 【redis-cli】客户端启动
  • 【redis-cli -h host -p port -a password】在远程服务上执行命令
  • 【ECHO "Hello World"】打印给定的字符串
  • 【DEL KEY_NAME】删除指定键
  • 【AUTH PASSWORD】鉴权登录
  • 【EXISTS KEY_NAME】是否存在指定键
  • 【Expire KEY_NAME TIME_IN_SECONDS】设置键的过期时间
  • 【SET KEY_NAME VALUE】设置键的值
  • 【GET KEY_NAME】获取键值
  • 【STRLEN KEY_NAME】获取键值的长度
  • 【APPEND KEY_NAME NEW_VALUE】拼接新值到旧值
  • 【config set requirepass xxx】设置密码为xxx
http://www.yayakq.cn/news/49748/

相关文章:

  • 化妆品网站设计开题报告黄岛因特网站建设公司
  • wordpress 人体时钟不同类型网站优化
  • 企业网站建设专业公司牡丹江站
  • 企业网站开发教程制作网站公司多少钱
  • 网站建设前期策划方案临沂网站建设选盛誉
  • 做网站怎么租个空间网页设计与制作实训总结3000字
  • 网站可以自己建立吗网页二级页面怎么做
  • 大型网站制作网站域名空间购买
  • 罗湖做网站联系电话怎么做网站建设销售
  • 怎么做公司网站竞价学习怎么做网站
  • 图片类网站开发需求廊坊seo软件
  • 网站幻灯片 按纽官网建设知识
  • 网站建设 关于我们做网站都需要什么贴吧
  • 推广网站实例自定义wordpress背景图片
  • 河北邢台做wap网站网络运维与安全就业方向
  • 做标书要不要做网站网络优化推广 网站开发建设
  • 做网站用哪个开发工具好华为官网商城手机价格
  • 买了个网站源码后要怎么用网页游戏排行榜奇迹
  • 学校网站开发招标企业seo顾问
  • 珠宝网站开发的背景网站建设运营思路
  • 网站所有权 备案唐河企业网站制作怎么样
  • 西安免费公司网站设计淮南网名
  • 大望路做网站的公司昆明网站建设公司猫咪科技
  • 网站 只收录首页官网优化 报价
  • php网站代做如何网站平台建设好
  • 网站建站网站哪家好源汇区建设局网站
  • 手机端网站开发书籍格力电器的网站建设评价
  • 网站建设中什么页面结构自己做一个网站一年的费用
  • 手机网站设计需求分析折扣卡网站建设
  • 建设企业网站公司在哪里好的网页网站设计