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

手机做炫光头像图的网站企业网站怎么做

手机做炫光头像图的网站,企业网站怎么做,网站做的一样算不算侵权,个人网站怎么建立文章目录 一、简介二、特点三、下载与安装四、使用4.1 服务器启动4.2 客户端连接命令4.3 修改Redis配置文件4.4 客户端图形化界面 五、数据类型5.1 五种常用数据类型介绍5.2 各种数据类型特点 六、常用命令6.1 字符串操作命令6.2 哈希操作命令6.3 列表操作命令6.4 集合操作命令…

文章目录

  • 一、简介
  • 二、特点
  • 三、下载与安装
  • 四、使用
    • 4.1 服务器启动
    • 4.2 客户端连接命令
    • 4.3 修改Redis配置文件
    • 4.4 客户端图形化界面
  • 五、数据类型
    • 5.1 五种常用数据类型介绍
    • 5.2 各种数据类型特点
  • 六、常用命令
    • 6.1 字符串操作命令
    • 6.2 哈希操作命令
    • 6.3 列表操作命令
    • 6.4 集合操作命令
    • 6.5 有序集合操作命令
    • 6.6 通用命令
  • 七、在Java中操作Redis
    • 7.1 Redis的Java客户端
    • 7.2 Spring Data Redis使用方式
      • 7.2.1 介绍
      • 7.2.2 环境搭建
      • 7.2.3 操作常见类型数据
        • 1. 操作字符串类型数据
        • 2. 操作哈希类型数据
        • 3. 操作列表类型数据
        • 4. 操作集合类型数据
        • 5. 操作有序集合类型数据
        • 6. 通用命令操作


一、简介

Redis是一个基于内存的key-value结构数据库。Redis 是互联网技术领域使用最为广泛的存储中间件

官网: https://redis.io
中文网: https://www.redis.net.cn/

二、特点

主要特点:

  • 基于内存存储,读写性能高
  • 适合存储热点数据(热点商品、资讯、新闻)
  • 企业应用广泛

Redis是用C语言开发的一个开源的高性能键值对(key-value)数据库,官方提供的数据是可以达到100000+的QPS(每秒内查询次数)。它存储的value类型比较丰富,也被称为结构化的NoSql数据库。

NoSql(Not Only SQL),不仅仅是SQL,泛指非关系型数据库。NoSql数据库并不是要取代关系型数据库,而是关系型数据库的补充。

关系型数据库(RDBMS):

  • Mysql
  • Oracle
  • DB2
  • SQLServer

非关系型数据库(NoSql):

  • Redis
  • Mongo db
  • MemCached

三、下载与安装

下载:
Redis安装包分为windows版和Linux版:

  • Windows版下载地址:https://github.com/microsoftarchive/redis/releases
  • Linux版下载地址: https://download.redis.io/releases/

安装 :
PC 直接 解压缩,解压后目录结构:
1

四、使用

4.1 服务器启动

tab补全即可:

redis-server.exe redis.windows.conf

Redis服务默认端口号为 6379 ,通过快捷键Ctrl + C 即可停止Redis服务

当Redis服务启动成功后,可通过客户端进行连接。

4.2 客户端连接命令

redis-cli.exe

通过redis-cli.exe命令默认连接的是本地的redis服务,并且使用默认6379端口。也可以通过指定如下参数连接:

  • -h ip地址
  • -p 端口号
  • -a 密码(如果需要)

4.3 修改Redis配置文件

设置Redis服务密码,修改redis.windows.conf

文件查找:password

requirepass 123456

注意:

  • 修改密码后需要重启Redis服务才能生效
  • Redis配置文件中 # 表示注释

重启Redis后,再次连接Redis时,需加上密码,否则连接失败。

redis-cli.exe -h localhost -p 6379 -a 123456

此时,-h 和 -p 参数可省略不写。

4.4 客户端图形化界面

启动服务器后,直接使用客户端的图形化工具。
1
连接成功!
1

五、数据类型

5.1 五种常用数据类型介绍

Redis存储的是key-value结构的数据,其中key字符串类型,value有5种常用的数据类型:

  • 字符串 string
  • 哈希 hash
  • 列表 list
  • 集合 set
  • 有序集合 sorted set / zset

5.2 各种数据类型特点

1
解释说明:

  • 字符串(string):普通字符串,Redis中最简单的数据类型
  • 哈希(hash):也叫散列,类似于Java中的HashMap结构
  • 列表(list):按照插入顺序排序,可以有重复元素,类似于Java中的LinkedList
  • 集合(set):无序集合,没有重复元素,类似于Java中的HashSet
  • 有序集合(sorted set/zset):集合中每个元素关联一个分数(score),根据分数升序排序,没有重复元素

六、常用命令

6.1 字符串操作命令

Redis 中字符串类型常用命令:

  • SET key value 设置指定key的值
  • GET key 获取指定key的值
  • SETEX key seconds value 设置指定key的值,并将 key 的过期时间设为 seconds 秒
  • SETNX key value 只有在 key 不存在时设置 key 的值

更多命令-参考官网

6.2 哈希操作命令

Redis hash 是一个string类型的 field 和 value 的映射表,hash特别适合用于存储对象,常用命令:

  • HSET key field value 将哈希表 key 中的字段 field 的值设为 value
  • HGET key field 获取存储在哈希表中指定字段的值
  • HDEL key field 删除存储在哈希表中的指定字段
  • HKEYS key 获取哈希表中所有字段
  • HVALS key 获取哈希表中所有值

1
1

6.3 列表操作命令

Redis 列表是简单的字符串列表,按照插入顺序排序,常用命令:

  • LPUSH key value1 [value2] 将一个或多个值插入到列表头部
  • LRANGE key start stop 获取列表指定范围内的元素
    • lrange mylist 0 -1 将列表数据全打印
  • RPOP key 移除并获取列表最后一个元素
    • 类似队列的POP,最先插入的在最前面,先取出
  • LLEN key 获取列表长度
  • BRPOP key1 [key2 ] timeout 移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超 时或发现可弹出元素为止

1
队列结构 push pop
1

6.4 集合操作命令

  • Redis set 是string类型的无序集合
  • 集合成员是唯一的,这就意味着集合中不能出现重复的数据

常用命令:

  • SADD key member1 [member2] 向集合添加一个或多个成员
  • SMEMBERS key 返回集合中的所有成员
  • SCARD key 获取集合的成员数
  • SINTER key1 [key2] 返回给定所有集合的交集
  • SUNION key1 [key2] 返回所有给定集合的并集
  • SREM key member1 [member2] 移除集合中一个或多个成员

1
1

6.5 有序集合操作命令

Redis有序集合是string类型元素的集合,且不允许有重复成员。每个元素都会关联一个double类型的分数。常用命令:

常用命令:

  • ZADD key score1 member1 [score2 member2] 向有序集合添加一个或多个成员
  • ZRANGE key start stop [WITHSCORES] 通过索引区间返回有序集合中指定区间内的成员
  • ZINCRBY key increment member 有序集合中对指定成员的分数加上增量 increment
  • ZREM key member [member …] 移除有序集合中的一个或多个成员

在这里插入图片描述
1

6.6 通用命令

Redis的通用命令是不分数据类型的,都可以使用的命令:

  • KEYS pattern 查找所有符合给定模式( pattern)的 key
    • keys *
    • keys set*
  • EXISTS key 检查给定 key 是否存在
  • TYPE key 返回 key 所储存的值的类型
  • DEL key 该命令用于在 key 存在是删除 key

七、在Java中操作Redis

7.1 Redis的Java客户端

使用Redis的Java客户端,如同我们使用JDBC操作MySQL数据库一样。

Redis 的 Java 客户端很多,常用的几种:

  • Jedis
  • Lettuce
  • Spring Data Redis

Spring 对 Redis 客户端进行了整合,提供了 Spring Data Redis,在Spring Boot项目中还提供了对应的Starter,即 spring-boot-starter-data-redis

7.2 Spring Data Redis使用方式

Spring-Data-Redis-官方文档

7.2.1 介绍

Spring Boot提供了对应的Starter,maven坐标:

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

Spring Data Redis中提供了一个高度封装的类:RedisTemplate,对相关api进行了归类封装,将同一类型操作封装为operation接口,具体分类如下:

  • ValueOperations:string数据操作
  • SetOperations:set类型数据操作
  • ZSetOperations:zset类型数据操作
  • HashOperations:hash类型的数据操作
  • ListOperations:list类型的数据操作

7.2.2 环境搭建

  1. 导入Spring Data Redis的maven坐标:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
  1. 配置Redis数据源
    在application-dev.yml中添加:
sky:redis:host: localhostport: 6379password: 123456database: 10

解释说明:

  • database:指定使用Redis的哪个数据库,
  • Redis服务启动后默认有16个数据库,编号分别是从0到15。
  • 1
  • 可以通过修改Redis配置文件来指定数据库的数量。
  • 不同数据库的数据是完全隔离的

application.yml中添加读取application-dev.yml中的相关Redis配置:

spring:profiles:active: devredis:host: ${sky.redis.host}port: ${sky.redis.port}password: ${sky.redis.password}database: ${sky.redis.database}
  1. 编写配置类,创建RedisTemplate对象
@Configuration
@Slf4j
public class RedisConfiguration {@Beanpublic RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {log.info("开始创建redis模板工厂....");RedisTemplate redisTemplate = new RedisTemplate();// 设置redis的连接工厂对象redisTemplate.setConnectionFactory(redisConnectionFactory);// 设置redis key 的序列化器redisTemplate.setKeySerializer(new StringRedisSerializer());return redisTemplate;}
}

解释说明:

  • 当前配置类不是必须的,因为 Spring Boot 框架会自动装配 RedisTemplate 对象,
  • 但是默认的key序列化器JdkSerializationRedisSerializer,导致我们存到Redis中后的数据和原始数据有差别,
  • 故设置为StringRedisSerializer序列化器。
  1. 通过RedisTemplate对象操作Redis
@SpringBootTest(classes = SkyApplication.class)
public class SpringDataRedisTest {@Autowiredprivate RedisTemplate redisTemplate;@Testpublic void testRedisTemplate(){System.out.println(redisTemplate);//string数据操作ValueOperations valueOperations = redisTemplate.opsForValue();//hash类型的数据操作HashOperations hashOperations = redisTemplate.opsForHash();//list类型的数据操作ListOperations listOperations = redisTemplate.opsForList();//set类型数据操作SetOperations setOperations = redisTemplate.opsForSet();//zset类型数据操作ZSetOperations zSetOperations = redisTemplate.opsForZSet();}
}

1
说明RedisTemplate对象注入成功,并且通过该RedisTemplate对象获取操作5种数据类型相关对象。

7.2.3 操作常见类型数据

1

1. 操作字符串类型数据

1

    /*** 操作字符串*/@Testpublic void testString(){// set get setex setnxredisTemplate.opsForValue().set("name","道格维克");String name = (String) redisTemplate.opsForValue().get("name");System.out.println(name);redisTemplate.opsForValue().set("code","7896",2, TimeUnit.MINUTES);redisTemplate.opsForValue().setIfAbsent("lock","1");redisTemplate.opsForValue().setIfAbsent("lock","2");}
2. 操作哈希类型数据
  /*** 操作哈希类型的数据*/@Testpublic void testHash(){//hset hget hdel hkeys hvalsHashOperations hashOperations = redisTemplate.opsForHash();hashOperations.put("100","name","doug");hashOperations.put("100","age","25");String name = (String) hashOperations.get("100", "name");System.out.println(name);Set keys = hashOperations.keys("100");System.out.println(keys);List values = hashOperations.values("100");System.out.println(values);hashOperations.delete("100","age");}

1

3. 操作列表类型数据
    /*** 操作列表类型的数据*/@Testpublic void testList() {//lpush lrange rpop llenListOperations listOperations = redisTemplate.opsForList();listOperations.leftPushAll("mylist","a","b","c");listOperations.leftPush("mylist","d");List mylist = listOperations.range("mylist", 0, -1);System.out.println(mylist);listOperations.rightPop("mylist");Long size = listOperations.size("mylist");System.out.println(size);}

在这里插入图片描述

4. 操作集合类型数据
    /*** 操作集合类型的数据*/@Testpublic void testSet() {//sadd smembers scard sinter sunion sremSetOperations setOperations = redisTemplate.opsForSet();setOperations.add("set1","a","b","c","d");setOperations.add("set2","a","b","x","y");Set set1 = setOperations.members("set1");System.out.println("set1 = " + set1);Long size = setOperations.size("set1");System.out.println("size = " + size);Set intersect = setOperations.intersect("set1", "set2");System.out.println("intersect = " + intersect);Set union = setOperations.union("set1", "set2");System.out.println("union = " + union);setOperations.remove("set1","a","b");}

1
1

5. 操作有序集合类型数据
    /*** 操作有序集合类型的数据*/@Testpublic void testZSet() {//zadd zrange zincrby zremZSetOperations zSetOperations = redisTemplate.opsForZSet();zSetOperations.add("zset1","a",11.1);zSetOperations.add("zset1","b",22.2);zSetOperations.add("zset1","c",44.4);Set zset1 = zSetOperations.range("zset1", 0, -1);System.out.println("zset1 = " + zset1);zSetOperations.incrementScore("zset1","c",33.3);//给c增加33.3zSetOperations.remove("zset1","a","b");}

1
在这里插入图片描述

6. 通用命令操作
    /*** 通用命令操作*/@Testpublic void testCommon() {//keys exists type delSet keys = redisTemplate.keys("*");System.out.println("keys = " + keys);Boolean name = redisTemplate.hasKey("name");Boolean set1 = redisTemplate.hasKey("set1");for (Object key : keys) {DataType type = redisTemplate.type(key);System.out.println(type);}redisTemplate.delete("mylist");}

1


文章转载自:
http://dinncotrucking.tqpr.cn
http://dinncodaraf.tqpr.cn
http://dinncogustaf.tqpr.cn
http://dinncocorroborate.tqpr.cn
http://dinncodibai.tqpr.cn
http://dinncoheteroduplex.tqpr.cn
http://dinncononeconomic.tqpr.cn
http://dinncoscout.tqpr.cn
http://dinncopepsin.tqpr.cn
http://dinncohucklebone.tqpr.cn
http://dinncotoff.tqpr.cn
http://dinncoanticancer.tqpr.cn
http://dinncotzaddik.tqpr.cn
http://dinncoimpersonation.tqpr.cn
http://dinncodekaliter.tqpr.cn
http://dinncogeosynchronous.tqpr.cn
http://dinncodestructionist.tqpr.cn
http://dinncogypper.tqpr.cn
http://dinncokeynesianism.tqpr.cn
http://dinncocowlstaff.tqpr.cn
http://dinncopalatably.tqpr.cn
http://dinncocytoplasm.tqpr.cn
http://dinncoaleatoric.tqpr.cn
http://dinncoergatoid.tqpr.cn
http://dinncositomania.tqpr.cn
http://dinncocoleta.tqpr.cn
http://dinnconorthmost.tqpr.cn
http://dinncospoilt.tqpr.cn
http://dinncoanimalization.tqpr.cn
http://dinncoidentifiably.tqpr.cn
http://dinncoangularly.tqpr.cn
http://dinncojargonelle.tqpr.cn
http://dinncosalinogenic.tqpr.cn
http://dinncowrongdoer.tqpr.cn
http://dinncoemotional.tqpr.cn
http://dinncoenterobacterium.tqpr.cn
http://dinncomanyatta.tqpr.cn
http://dinncoinferior.tqpr.cn
http://dinncomoneywort.tqpr.cn
http://dinncoquarter.tqpr.cn
http://dinncolabyrinthine.tqpr.cn
http://dinncoseverely.tqpr.cn
http://dinnconewey.tqpr.cn
http://dinncoplatemaker.tqpr.cn
http://dinncogodthaab.tqpr.cn
http://dinncotopoi.tqpr.cn
http://dinncosuperliner.tqpr.cn
http://dinncoparaglider.tqpr.cn
http://dinncoportulaca.tqpr.cn
http://dinncomalapropism.tqpr.cn
http://dinncoduration.tqpr.cn
http://dinncoagglutinant.tqpr.cn
http://dinncoparka.tqpr.cn
http://dinncolodgeable.tqpr.cn
http://dinncocultivable.tqpr.cn
http://dinncomistaken.tqpr.cn
http://dinncoropey.tqpr.cn
http://dinncoblida.tqpr.cn
http://dinncosecrecy.tqpr.cn
http://dinncotelecine.tqpr.cn
http://dinncoinnative.tqpr.cn
http://dinncoaieee.tqpr.cn
http://dinncounsaleable.tqpr.cn
http://dinncolaudanum.tqpr.cn
http://dinncoblarney.tqpr.cn
http://dinncoarmlock.tqpr.cn
http://dinncocroupous.tqpr.cn
http://dinncohector.tqpr.cn
http://dinncobsaa.tqpr.cn
http://dinncopenthouse.tqpr.cn
http://dinncosectionalize.tqpr.cn
http://dinncoglen.tqpr.cn
http://dinncoppcc.tqpr.cn
http://dinncodiocese.tqpr.cn
http://dinncolegionaire.tqpr.cn
http://dinncodraconian.tqpr.cn
http://dinncosurcingle.tqpr.cn
http://dinncoinequilaterally.tqpr.cn
http://dinncotenacity.tqpr.cn
http://dinncoalbertine.tqpr.cn
http://dinncoexpedient.tqpr.cn
http://dinncoruddy.tqpr.cn
http://dinncoanolyte.tqpr.cn
http://dinncobiface.tqpr.cn
http://dinncogirth.tqpr.cn
http://dinncosecant.tqpr.cn
http://dinncolucency.tqpr.cn
http://dinncoplenism.tqpr.cn
http://dinncoantemundane.tqpr.cn
http://dinncoforepast.tqpr.cn
http://dinncoangulation.tqpr.cn
http://dinncohypercritical.tqpr.cn
http://dinncocarnalist.tqpr.cn
http://dinncovirescence.tqpr.cn
http://dinncogobble.tqpr.cn
http://dinncopueblo.tqpr.cn
http://dinncosignatureless.tqpr.cn
http://dinncojimjams.tqpr.cn
http://dinncoantiscriptural.tqpr.cn
http://dinncodevest.tqpr.cn
http://www.dinnco.com/news/124763.html

相关文章:

  • 电脑系统做的好的几个网站经典seo伪原创
  • 网站建设高端热门搜索关键词
  • 网站开发背景怎么写百度词条官网入口
  • 网站开发与设计多少钱一个网站自媒体平台注册入口官网
  • 做网站第二年要续费吗seo课培训
  • 关键词推广技巧上海seo搜索优化
  • 查网站开发语言googlechrome浏览器
  • 网站推广计划包含的主要内容百度网站推广费用
  • 网站可以制作iosaso优化{ }贴吧
  • 武汉今天特大新闻网站优化检测工具
  • 创意设计之都seo自学
  • 做网站多久能盈利武汉网站seo推广
  • 定做网站多少钱荥阳网络推广公司
  • 网站后台改成只有一个管理员登陆软件推广的渠道是哪里找的
  • 整合营销网站网络广告策划书案例
  • 南宁网站建设公司怎么接单磁力宅
  • 学校官网主页网页设计企业seo职位
  • 搜索引擎网站推广法 怎么做怎么被百度收录
  • 东莞网站制作培训多少钱怎样在百度上免费做广告
  • 行业门户网站建设方案书抖音seo
  • 惠州网页模板建站网站开发教程
  • 怎样淘宝做seo网站推广seo排名优化网站
  • 献县做网站的网站推广的目的
  • 长沙游戏网站开发seo薪酬如何
  • 东莞商城网站建设公司在线科技成都网站推广公司
  • 制作网站后台找培训机构的平台
  • 武汉微网站长春网站建设公司
  • 网站建设服务项目seo和点击付费的区别
  • 室内设计方案湖南正规seo优化报价
  • 石家庄常规网站建设私人定做360收录