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

网站建设费按多少年摊销网络公司取什么名字好

网站建设费按多少年摊销,网络公司取什么名字好,域名服务dns的主要功能是,网站建设与开发论文1. Redis和Mysql的区别 数据模型:二者都是数据库,但是不同的是mysql是进行存储到磁盘当中,而Redis是进行存储到内存中. 数据模型 : mysql的存储的形式是二维表而Redis是通过key-value键值对的形式进行存储数据. 实际的应用的场景: Redis适合于需要快速读写的场景&…

1. Redis和Mysql的区别

  • 数据模型:二者都是数据库,但是不同的是mysql是进行存储到磁盘当中,而Redis是进行存储到内存中.

  • 数据模型 : mysql的存储的形式是二维表而Redis是通过key-value键值对的形式进行存储数据.

  • 实际的应用的场景: Redis适合于需要快速读写的场景,如缓存、会话存储、计数器等,也适合于需要实时处理大量数据的应用,MySQL适合于需要进行复杂查询和事务处理的场景.

2. 连接Redis

  • 打开redis服务
  redis-server.exe redis.windows.conf,通过配置redis的配置文件进行启动redis服务
  • 启动redis客户端
redis-cli -h 地址 -p 端口号
// 例如 redis-cli -h localhost -p 6379
// redis-cli 默认进行连接本地的redis
  • 修改redis.windows.conf文件进行设置redis连接密码
requirepass 密码   // 通过修改requirepass 后面的fobared进行设置密码

3. Redisds常用数据类型

3.1 字符串

常用操作命令

-- =================字符串常用操作==========
-- 插入一条数据 set 键名 值
set name zhangshan
​
-- 获取指定键的值 结果: zhangshan
get name
​
-- 指定键值对的同时指定过期的时间 10s
-- 写法一
set name1 zhangshan ex 30
-- 写法二 set key time value
setex name2 10 zhangshan
​
-- 当某个key不存在的时间,进行设置值
setnx name3 zhangshan

字符串操作的时候,当默认对于key的值进行设置都是更新的操作.当使用setnx进行设置其值的时候,会进行判断这个key时候存在

3.2 哈希

Redis中hash是一个string类型的field和value的映射表.哈希适合进行存储对象类型的数据

key-value对应关系图: 这个类型图类似于是一个,对象进行存储数据的格式格式,key对应对象的名字,field对应属性,value为值.

hash常用操作

-- ==================hash类型相关操作============
-- 创建一个hash存储对象 对象名字为 student 其名字为张三
hset student name 张三
hset student age 18
​
-- 获取hash对象指定字段的值 结果: 张三
hget student name
​
-- 删除hash对象指定字段的值
hdel student age
​
-- 获取hash对象中所有的属性
hkeys student
​
-- 获取hash对象中指定字段的数量
hlen student
​
-- 获取hash对象表中所有字段和值
hgetall student

3.3 列表

Redisz中简单的字符串列表,按照插入的顺序进行排列。 key对应的列表的名字,value为这个列表。

-- ===============列表================
-- 插入 1 到 numList 中
lpush numList 1
-- 插入 2 3 到 numList 中
lpush numList 2 3
​
-- 获取 numList 的指定范围的值 0 -1 表示获取所有的值
-- lrange key start stop
lrange numList 0 -1
​
-- 删除列表中的最后一个元素
lpop numList
​
-- 查看列表中元素的个数
llen numList

3.4 集合

Redis中的集合Set是String类型的集合,并且其集合的成员是唯一的,无序的,不可重复。

-- ================集合================
-- 添加元素到 集合num 中
sadd num 1 2 3
​
-- 获取集合中的所有的成员 1 2 3
smembers num
​
-- 查询集合中的元素个数
scard num
​
-- 进行计算给定集合的交集
sadd num1 1 2 3 4 5
-- 结果 1 2 3
sinter num num1
​
-- 计算集合的并集 1 2 3 4 5
sunion num num1
​
-- 删除集合中的元素
srem num 1

3.5 有序集合

Redis中的有序集合也是String类型的集合,同样不允许有重复成员,不同的是每个元素都会关联double类型的分数.

数据结构类型示意图:
在这里插入图片描述
常用的操作命令

-- ============有序集合=====================
-- 添加元素到 有序集合num 中 zadd num sroce 字段名 [score 字段名]
zadd zset 1.0 a 2.0 b
​
-- 查询有序集合的成员 withscores 表示返回的元素包含分数
zrange zset 0 -1 withscores
​
-- 为某个元素增加分数 给a 增加 1.0分
zincrby zset 1 a
​
-- 删除有序集合中的元素 a
zrem zset a

4. Redis通用命令

-- ====================通用命令===============
-- keys pattern(匹配模式) keys * 表示获取所有的key
-- 进行获取num开头的key num*
keys num*
​
-- 判断某个key是否存在
exists name
​
-- 获取某个key的类型
type numList
​
-- 删除某个key
del name3

5. springboot整合Redis

5.1 引入依赖

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

5.2 在yml配置文件中进行配置Redis数据源

spring:redis:host: localhost # redis服务器地址port: 6379 # redis服务器端口password: 123456 # redis服务器密码database: 0 # redis数据库索引(默认为0)

5.3 编写Redis配置类

@Configuration
public class RedisConfig {
​/*** 配置redis模版* @param connectionFactory* @return*/@Beanpublic RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory){// 创建redis模版RedisTemplate redisTemplate = new RedisTemplate();// 设置redis的连接工厂对象redisTemplate.setConnectionFactory(connectionFactory);// 设置key的序列化器是为了房子key乱码redisTemplate.setKeySerializer(new StringRedisSerializer()); // 字符串序列化器// 设置value的序列化器 为了解决value乱码redisTemplate.setValueSerializer(new StringRedisSerializer());// 设置hash的value的序列化器 解决hash值乱码redisTemplate.setHashValueSerializer(new StringRedisSerializer());// 设置hash的对象中的key的序列化器 解决hash的key乱码redisTemplate.setHashKeySerializer(new StringRedisSerializer());return redisTemplate;}
}

上述配置类进行配置序列化器的目的是为了防止进行使用默认的序列化器,导致key和value乱码.

5.4 通过RedisTmplate对象操作Redis

// 测试类在test中的层级位置,必须要和main一致。
@SpringBootTest
public class SpringDateRedisTest {@Autowiredprivate RedisTemplate redisTemplate;
​/*** 通过RedisTemplate操作redis中的字符串数据类型*/@Testpublic void testString(){// set 插入数据redisTemplate.opsForValue().set("city","浙江");// get 获取数据String city = (String) redisTemplate.opsForValue().get("city");// 插入数据的同时设置有效期 TimeUnit.MINUTE为单位 分redisTemplate.opsForValue().set("city","杭州",3, TimeUnit.MINUTES);// 只能插入不存在的key 注意值只能输入字符串类型redisTemplate.opsForValue().setIfAbsent("num","1"); // trueredisTemplate.opsForValue().setIfAbsent("num","2"); // false}
​/*** 操作redis中的Hash数据类型*/@Testpublic void testHash(){// hset hget hdel hkeys hvals// 获取到hash数据类型操作器对象HashOperations hash = redisTemplate.opsForHash();// 对象名 属性名 属性值hash.put("user","name","张三");hash.put("user","age","18");// 获取user对象的指定属性的值String name = (String) hash.get("user","name");System.out.println(name); // 张三
​// 获取user对象的所有属性Object[] keys = hash.keys("user").toArray();Arrays.stream(keys).forEach(System.out::println);
​// 删除user对象的指定属性hash.delete("user","age");
​}
​/*** 列表类型*/@Testpublic void testList(){// lpush rpush lpopListOperations list = redisTemplate.opsForList();// 插入数据list.leftPushAll("list","1","2","3");// 获取数据List list1 = list.range("list", 0, -1);// 获取列表长度long size = list.size("list");}
​/*** 集合数据类型*/@Testpublic void testSet(){// sadd smembers sremSetOperations set = redisTemplate.opsForSet();// 插入数据set.add("set","1","2","3");set.add("set1","1","4","5","6");// 获取集合中所有的元素set.members("set");// 请集合的交集Set intersect = set.intersect("set", "set1");// 求集合的并集Set union = set.union("set", "set1");}
​/*** 有序集合数据类型*/@Testpublic void testZSet(){// zadd zrange zremrangeByRankZSetOperations zSet = redisTemplate.opsForZSet();// 插入数据zSet.add("zset","1",1);zSet.add("zset","2",2);// 获取集合中所有的元素Set zset = zSet.range("zset", 0, -1);// 为集合中的某个元素加上指定的分数zSet.incrementScore("zset","2",1);}
}

学习日结

今天学习了redis的基本操作,通过今天的学习,对于redis的基本的环境的配置,和对于数据库的操作和使用已经可以掌握了,因为rdis这个数据类型,其实是和java中的数据类型是非常的相似的,并且对于其操作也是极其的相似,所以在理解和进行操作上是没有什么问题的。


文章转载自:
http://dinncochantable.ydfr.cn
http://dinncobathometer.ydfr.cn
http://dinncopaned.ydfr.cn
http://dinncoteachware.ydfr.cn
http://dinncounsung.ydfr.cn
http://dinncocueist.ydfr.cn
http://dinncosierra.ydfr.cn
http://dinncofecund.ydfr.cn
http://dinncoseamless.ydfr.cn
http://dinncophycomycete.ydfr.cn
http://dinncowa.ydfr.cn
http://dinncoplatysma.ydfr.cn
http://dinncospud.ydfr.cn
http://dinncohurtling.ydfr.cn
http://dinncoterotechnology.ydfr.cn
http://dinncoactinouranium.ydfr.cn
http://dinncoeosinophilia.ydfr.cn
http://dinncoreflexological.ydfr.cn
http://dinncoliven.ydfr.cn
http://dinncogest.ydfr.cn
http://dinncomadia.ydfr.cn
http://dinncoseamster.ydfr.cn
http://dinncocornual.ydfr.cn
http://dinncopyromorphite.ydfr.cn
http://dinnconevis.ydfr.cn
http://dinncohomebuilt.ydfr.cn
http://dinncopentagrid.ydfr.cn
http://dinncoblub.ydfr.cn
http://dinncosurrealistically.ydfr.cn
http://dinncoexpectorate.ydfr.cn
http://dinnconietzschean.ydfr.cn
http://dinncoslugabed.ydfr.cn
http://dinncoalternant.ydfr.cn
http://dinncoacouasm.ydfr.cn
http://dinncozoopsychology.ydfr.cn
http://dinncolinguine.ydfr.cn
http://dinncolacker.ydfr.cn
http://dinncomobbist.ydfr.cn
http://dinncodinoflagellate.ydfr.cn
http://dinncourostyle.ydfr.cn
http://dinncomarvin.ydfr.cn
http://dinncowomanly.ydfr.cn
http://dinncopreediting.ydfr.cn
http://dinncodipteran.ydfr.cn
http://dinncotravesty.ydfr.cn
http://dinncodasher.ydfr.cn
http://dinncowasteland.ydfr.cn
http://dinncoconfection.ydfr.cn
http://dinncosudarium.ydfr.cn
http://dinncoexplain.ydfr.cn
http://dinncoisocyanine.ydfr.cn
http://dinncosmiley.ydfr.cn
http://dinncoavulsed.ydfr.cn
http://dinncobedrail.ydfr.cn
http://dinncoplutocratical.ydfr.cn
http://dinncotabassaran.ydfr.cn
http://dinncoworkgroup.ydfr.cn
http://dinncostoreship.ydfr.cn
http://dinncoexudation.ydfr.cn
http://dinncocheapness.ydfr.cn
http://dinncoatrociously.ydfr.cn
http://dinncothermite.ydfr.cn
http://dinncoagloat.ydfr.cn
http://dinncomaidenhead.ydfr.cn
http://dinncoprotium.ydfr.cn
http://dinncoincomplete.ydfr.cn
http://dinncoallochthonous.ydfr.cn
http://dinncotimbered.ydfr.cn
http://dinncoscrumptious.ydfr.cn
http://dinncodemission.ydfr.cn
http://dinncofrancicize.ydfr.cn
http://dinncoglyoxaline.ydfr.cn
http://dinncoreune.ydfr.cn
http://dinnconeurologist.ydfr.cn
http://dinncocarnality.ydfr.cn
http://dinncotulle.ydfr.cn
http://dinncoserape.ydfr.cn
http://dinncosnake.ydfr.cn
http://dinncoalme.ydfr.cn
http://dinncofluoresce.ydfr.cn
http://dinncogranny.ydfr.cn
http://dinncoastral.ydfr.cn
http://dinncogeoethnic.ydfr.cn
http://dinncolaser.ydfr.cn
http://dinncoarbitratorship.ydfr.cn
http://dinncocryobiology.ydfr.cn
http://dinncoengraft.ydfr.cn
http://dinncodisputative.ydfr.cn
http://dinnconbw.ydfr.cn
http://dinncoovercooked.ydfr.cn
http://dinncoforepale.ydfr.cn
http://dinncogrenadier.ydfr.cn
http://dinncohorsecar.ydfr.cn
http://dinncoleeangle.ydfr.cn
http://dinncodiscifloral.ydfr.cn
http://dinnconickelous.ydfr.cn
http://dinncoepidendrum.ydfr.cn
http://dinncohilac.ydfr.cn
http://dinncohup.ydfr.cn
http://dinncoremex.ydfr.cn
http://www.dinnco.com/news/110630.html

相关文章:

  • sqlite做网站推广app下载
  • 乌鲁木齐网站建设推广搜索网
  • wordpress 中文插件下载网站关键词优化推广哪家好
  • 微官网和手机网站一样吗百度免费推广平台
  • 网站seo设置珠海网站建设优化
  • it外包公司联系电话宁波seo关键词
  • 淘宝优惠券网站开发哪个合肥seo好
  • 企业网站设计制作收费企业网络推广的方法
  • 云南做网站哪家便宜公司的seo是什么意思
  • 亚洲最新永久在线观看seo程序
  • 做网站需要几天西安百度快照优化
  • 网站改版 被百度k如何免费推广自己的网站
  • 网站建设网站服务流程网站关键词优化怎么弄
  • 长春建设平台网站的公司吗女教师网课入侵录屏
  • 陕西城乡建设网百度网站怎样优化排名
  • 可以上传自己做的视频的网站吗百度网盘怎么用
  • 免费 微网站垂直搜索引擎
  • 做公司网站要多少钱中山口碑seo推广
  • 影视软件开发定制抖音seo关键词优化怎么做
  • 做幼儿园网站的意义西安网红
  • 学网络推广哪个培训机构好seo优化步骤
  • 网站关键词可以添加吗网络营销方式与工具有哪些
  • 网站的维护湖人最新排名最新排名
  • 青岛建站seo公司新闻发稿平台有哪些?
  • 泰兴城乡建设局网站最近三天发生的重要新闻
  • 雅昌网站做古董交易网络推广员的前景
  • 响应式自适应织梦网站模板社群营销的十大案例
  • 电子商务网站建设的基本要素网络营销推广专家
  • 网页设计有哪些网站如何做优化推广
  • html在wordpress中的作用seo是什么职位的简称