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

网站定制兴田德润i在哪里舆情信息

网站定制兴田德润i在哪里,舆情信息,dede网站不能运行php文件,vip网站解析建设部分内容参考:阿里redis开发规范 同时,结合shigen在实习中的实践经验总结。 key的名称设计 可读性和管理性 业务名: 表名: id pro:user:1001简洁性 控制key的长度,可以用缩写 transaction -> tras拒绝bigkey 防止网卡流量、慢查询&…

部分内容参考:阿里redis开发规范 同时,结合shigen在实习中的实践经验总结。

key的名称设计

可读性和管理性

业务名: 表名: id

pro:user:1001

简洁性

控制key的长度,可以用缩写

transaction -> tras

拒绝bigkey

防止网卡流量、慢查询,string 类型控制在 10KB 以内,hash、list、set、zset 元素个数不要超过 5000

非字符串的 bigkey,不要使用 del 删除,使用 hscan、sscan、zscan 方式渐进式删除,同时要注意防止 bigkey 过期时间自动删除问题 (例如一个 200 万的 zset 设置 1 小时过期,会触发 del 操作,造成阻塞,而且该操作不会不出现在慢查询中 (latency 可查)),查找方法和删除方法

选择合适的数据类型

数据结构描述常用场景
String字符串类型,可存储文本或二进制数据缓存、计数器、分布式锁等
Hash键值对的无序集合存储对象、缓存、配置信息等
List有序的字符串元素集合消息队列、最新消息获取、粉丝列表等
Set无序且唯一的字符串元素集合标签系统、好友关系、集合操作等
Sorted Set有序的字符串元素集合,每个元素关联一个分数排行榜、范围查询、优先级队列等
Bitmap位数组,可进行位级别的操作用户在线状态、统计活跃用户等
HyperLogLog基数估计算法,用于统计唯一元素的数量网站UV统计、独立用户计数等
Geospatial地理空间位置(经纬度)与元素之间的映射关系地理位置查询、附近的人等
Pub/Sub发布者/订阅者模式,用于实现消息发布和订阅机制实时消息通知、事件驱动等
Streams类似于日志的有序消息流消息队列、事件溯源、实时分析等

控制key的生命周期

防止key集中过期-> 缓存雪崩

命令的使用

1、O(N) 命令关注 N 的数量

例如 hgetall、lrange、smembers、zrange、sinter 等并非不能使用,但是需要明确 N 的值。有遍历的需求可以使用 hscan、sscan、zscan 代替。

ZSCAN myset 0 MATCH prefix:* COUNT 10

2、禁用命令

禁止线上使用 keys、flushall、flushdb 等,通过 redis 的 rename 机制禁掉命令,或者使用 scan 的方式渐进式处理。

scan删除keys的shell脚本:

#!/bin/bash# 连接到 Redis 服务器
REDIS_CLI="/path/to/redis-cli"
HOST="localhost"
PORT="6379"
DB="0"# 定义删除操作函数
delete_all_keys() {# 初始化游标cursor="0"while true; do# 执行 SCAN 命令response="$($REDIS_CLI -h $HOST -p $PORT -n $DB SCAN $cursor)"# 解析 SCAN 命令的返回值cursor="$(echo "$response" | head -n 1)"keys="$(echo "$response" | tail -n +2)"# 删除当前页的所有键for key in $keys; do$REDIS_CLI -h $HOST -p $PORT -n $DB DEL "$key"done# 如果已经迭代完成了所有键if [ "$cursor" == "0" ]; thenbreakfidone
}# 调用删除操作函数
delete_all_keys

3、合理使用 select

redis 的多数据库较弱,使用数字进行区分,很多客户端支持较差,同时多业务用多数据库实际还是单线程处理,会有干扰。

4、使用批量操作提高效率

  • 原生命令:例如 mget、mset。
  • 非原生命令:可以使用 pipeline 提高效率。

但要注意控制一次批量操作的元素个数 (例如 500 以内,实际也和元素字节数有关)。

注意两者不同:

  • 原生是原子操作,pipeline 是非原子操作
  • pipeline 可以打包不同的命令,原生做不到
  • pipeline 需要客户端和服务端同时支持

5、不建议过多使用 Redis 事务功能

Redis 的事务功能较弱 (不支持回滚),而且集群版本(自研和官方) 要求一次事务操作的 key 必须在一个 slot 上(可以使用 hashtag 功能解决)

官方:redis设计成单线程,就是为了提升效率

6、Redis 集群版本在使用 Lua 上有特殊要求

1、所有 key 都应该由 KEYS 数组来传递,redis.call/pcall 里面调用的 redis 命令,key 的位置,必须是 KEYS array, 否则直接返回 error,“-ERR bad lua script for redis cluster, all the keys that the script uses should be passed using the KEYS arrayrn”

2、所有 key,必须在 1 个 slot 上,否则直接返回 error, “-ERR eval/evalsha command keys must in same slotrn”

7、monitor 命令

必要情况下使用 monitor 命令时,要注意不要长时间使用。

客户端的使用

避免多个应用使用一个redis实例

不想干的业务拆分,公共数据做服务化

使用连接池

有效的控制链接、提高效率,shigen在之前的文章中也分享过

合理的加密

redis密码的设置

淘汰策略

根据自身业务类型,选好 maxmemory-policy(最大内存淘汰策略),设置好过期时间。

默认策略是 volatile-lru,即超过最大内存后,在过期键中使用 lru 算法进行 key 的剔除,保证不过期数据不被删除,但是可能会出现 OOM 问题。

其他策略如下:

  • allkeys-lru:根据 LRU 算法删除键,不管数据有没有设置超时属性,直到腾出足够空间为止。
  • allkeys-random:随机删除所有键,直到腾出足够空间为止。
  • volatile-random: 随机删除过期键,直到腾出足够空间为止。
  • volatile-ttl:根据键值对象的 ttl 属性,删除最近将要过期数据。如果没有,回退到 noeviction 策略。
  • noeviction:不会剔除任何数据,拒绝所有写入操作并返回客户端错误信息 “(error) OOM command not allowed when used memory”,此时 Redis 只响应读操作。

相关工具

删除 bigkey

案例中展示的是java的操作,可以根据实际的情况改写成shell或python脚本

1、Hash 删除: hscan + hdel
public void delBigHash(String host, int port, String password, String bigHashKey) {Jedis jedis = new Jedis(host, port);if (password != null && !"".equals(password)) {jedis.auth(password);}ScanParams scanParams = new ScanParams().count(100);String cursor = "0";do {ScanResult<Entry<String, String>> scanResult = jedis.hscan(bigHashKey, cursor, scanParams);List<Entry<String, String>> entryList = scanResult.getResult();if (entryList != null && !entryList.isEmpty()) {for (Entry<String, String> entry : entryList) {jedis.hdel(bigHashKey, entry.getKey());}}cursor = scanResult.getStringCursor();} while (!"0".equals(cursor));//删除bigkeyjedis.del(bigHashKey);
}
2、List 删除: ltrim
public void delBigList(String host, int port, String password, String bigListKey) {Jedis jedis = new Jedis(host, port);if (password != null && !"".equals(password)) {jedis.auth(password);}long llen = jedis.llen(bigListKey);int counter = 0;int left = 100;while (counter < llen) {//每次从左侧截掉100个jedis.ltrim(bigListKey, left, llen);counter += left;}//最终删除keyjedis.del(bigListKey);
}
3、Set 删除: sscan + srem
public void delBigSet(String host, int port, String password, String bigSetKey) {Jedis jedis = new Jedis(host, port);if (password != null && !"".equals(password)) {jedis.auth(password);}ScanParams scanParams = new ScanParams().count(100);String cursor = "0";do {ScanResult<String> scanResult = jedis.sscan(bigSetKey, cursor, scanParams);List<String> memberList = scanResult.getResult();if (memberList != null && !memberList.isEmpty()) {for (String member : memberList) {jedis.srem(bigSetKey, member);}}cursor = scanResult.getStringCursor();} while (!"0".equals(cursor));//删除bigkeyjedis.del(bigSetKey);
}
4、SortedSet 删除: zscan + zrem
public void delBigZset(String host, int port, String password, String bigZsetKey) {Jedis jedis = new Jedis(host, port);if (password != null && !"".equals(password)) {jedis.auth(password);}ScanParams scanParams = new ScanParams().count(100);String cursor = "0";do {ScanResult<Tuple> scanResult = jedis.zscan(bigZsetKey, cursor, scanParams);List<Tuple> tupleList = scanResult.getResult();if (tupleList != null && !tupleList.isEmpty()) {for (Tuple tuple : tupleList) {jedis.zrem(bigZsetKey, tuple.getElement());}}cursor = scanResult.getStringCursor();} while (!"0".equals(cursor));//删除bigkeyjedis.del(bigZsetKey);
}

文章转载自:
http://dinncorudderhead.bkqw.cn
http://dinncohexabiose.bkqw.cn
http://dinncofairbanks.bkqw.cn
http://dinncoplacentology.bkqw.cn
http://dinncosideseat.bkqw.cn
http://dinncobroadcast.bkqw.cn
http://dinncojoyswitch.bkqw.cn
http://dinncowinterthur.bkqw.cn
http://dinncofabricator.bkqw.cn
http://dinncobookmark.bkqw.cn
http://dinncomonophysite.bkqw.cn
http://dinncopentastylos.bkqw.cn
http://dinncophilanderer.bkqw.cn
http://dinncohorrible.bkqw.cn
http://dinncosuccour.bkqw.cn
http://dinncovoyageur.bkqw.cn
http://dinncoevidence.bkqw.cn
http://dinncowarrant.bkqw.cn
http://dinncoreenlist.bkqw.cn
http://dinncoidentifier.bkqw.cn
http://dinncothyroadenitis.bkqw.cn
http://dinncofaecula.bkqw.cn
http://dinncorics.bkqw.cn
http://dinncoviewphone.bkqw.cn
http://dinncocrime.bkqw.cn
http://dinncostreetwalker.bkqw.cn
http://dinncoscanner.bkqw.cn
http://dinncoquodlibetz.bkqw.cn
http://dinncomaquette.bkqw.cn
http://dinncospartacus.bkqw.cn
http://dinncoecthlipses.bkqw.cn
http://dinncobathetic.bkqw.cn
http://dinncoinstate.bkqw.cn
http://dinncogalatians.bkqw.cn
http://dinncocinemagoer.bkqw.cn
http://dinncobleareye.bkqw.cn
http://dinncominiate.bkqw.cn
http://dinncosalangane.bkqw.cn
http://dinncoare.bkqw.cn
http://dinncohijaz.bkqw.cn
http://dinncocounterpoise.bkqw.cn
http://dinncoproteinic.bkqw.cn
http://dinncopipkin.bkqw.cn
http://dinncochemoceptor.bkqw.cn
http://dinncomourner.bkqw.cn
http://dinncovasculature.bkqw.cn
http://dinncosteamer.bkqw.cn
http://dinncopellagra.bkqw.cn
http://dinncokcps.bkqw.cn
http://dinncouniversalise.bkqw.cn
http://dinncocheque.bkqw.cn
http://dinncoanimadvert.bkqw.cn
http://dinncowhitleyism.bkqw.cn
http://dinncofrancolin.bkqw.cn
http://dinncobolshevistic.bkqw.cn
http://dinncofoxiness.bkqw.cn
http://dinncospontaneously.bkqw.cn
http://dinncovela.bkqw.cn
http://dinncoasterid.bkqw.cn
http://dinncooont.bkqw.cn
http://dinncoamplificatory.bkqw.cn
http://dinnconouny.bkqw.cn
http://dinncomanilla.bkqw.cn
http://dinncosheargrass.bkqw.cn
http://dinncomaidless.bkqw.cn
http://dinncoluminance.bkqw.cn
http://dinncofeathered.bkqw.cn
http://dinncoacademese.bkqw.cn
http://dinncocompletely.bkqw.cn
http://dinncoseraph.bkqw.cn
http://dinncoquinoidine.bkqw.cn
http://dinncofibroma.bkqw.cn
http://dinncodenegation.bkqw.cn
http://dinncopermanence.bkqw.cn
http://dinncofatherliness.bkqw.cn
http://dinncoauxochrome.bkqw.cn
http://dinncohilt.bkqw.cn
http://dinncomargent.bkqw.cn
http://dinncocolourize.bkqw.cn
http://dinncocompactible.bkqw.cn
http://dinncoheroically.bkqw.cn
http://dinncoauriculate.bkqw.cn
http://dinncocontracyclical.bkqw.cn
http://dinncovenae.bkqw.cn
http://dinncopinouts.bkqw.cn
http://dinncoteachware.bkqw.cn
http://dinncolieabed.bkqw.cn
http://dinncopise.bkqw.cn
http://dinnconobbut.bkqw.cn
http://dinncogalero.bkqw.cn
http://dinncovacillating.bkqw.cn
http://dinncovisualist.bkqw.cn
http://dinncomoonseed.bkqw.cn
http://dinncooperculiform.bkqw.cn
http://dinncoessentialist.bkqw.cn
http://dinncodidact.bkqw.cn
http://dinncosket.bkqw.cn
http://dinncoathene.bkqw.cn
http://dinncokist.bkqw.cn
http://dinncoplanter.bkqw.cn
http://www.dinnco.com/news/118725.html

相关文章:

  • 免费的企业宣传模板关键词优化是怎么做的
  • 石家庄哪里做微网站链接制作软件
  • 企业宣传册模板seo指搜索引擎
  • 祥云县住房和城乡建设局网站网站seo策划
  • 企业微网站建设小程序开发公司
  • 如何自己做电影网站山西seo排名厂家
  • 国产4k高清电视十大排名四川seo
  • 淮安做网站网络营销有哪些模式
  • 京东当前网站做的营销活动线上营销工具
  • 网站建设网站网站建设网站seo顾问服
  • 做家电维修网站能接到单吗最热门的短期培训课程
  • 网站建设 博采网络百度网站
  • 做网站怎么租个域名网站入口百度
  • asp网站安全吗常州网站建设
  • 做网站建设的注意事项武汉网站搜索引擎优化
  • ui设计师需要考证吗网站关键词怎样优化
  • 兰州网站seo按天计费网站推广主要是做什么
  • 自动化设计网站建设青岛网站建设公司哪家好
  • 新疆建设云网站怎么查询证书吉林黄页电话查询
  • 多少网站域名采用中文整站seo排名外包
  • ideo设计公司官网免费seo软件
  • 广西注册公司网站十大免费最亏的免费app
  • 网站程序引擎十大营销策略
  • 外贸企业网站红色风格怎么给自己的公司做网站
  • 昆明网站建设公司口碑营销的特征
  • 买域名后 怎么做网站百度竞价排名查询网站
  • 网站建设最关键的两个素材app拉新佣金排行榜
  • 不会代码可不可以做网站广州网络运营课程培训班
  • 图片网站 建站网络营销推广方案策划
  • 呼和浩特市做网站的企业深圳seo优化服务