缓存穿透/击穿/雪崩及其解决方案
1. 缓存的穿透/击穿/雪崩 缓存穿透:缓存穿透是指查询一个一定不存在的数据,由于缓存是不命中时需要从数据库查询,查不到数据则不写入缓存,这将导致这个不存在的数据每次请求都要到数据库去查询,进而给数据库带来压力。 缓存击穿:缓存击穿是指热点key在某个时间点过期的时候,而恰好在这个时间点对这个Key有大量的并发请求过来,从而大量… 阅读更多 »缓存穿透/击穿/雪崩及其解决方案
1. 缓存的穿透/击穿/雪崩 缓存穿透:缓存穿透是指查询一个一定不存在的数据,由于缓存是不命中时需要从数据库查询,查不到数据则不写入缓存,这将导致这个不存在的数据每次请求都要到数据库去查询,进而给数据库带来压力。 缓存击穿:缓存击穿是指热点key在某个时间点过期的时候,而恰好在这个时间点对这个Key有大量的并发请求过来,从而大量… 阅读更多 »缓存穿透/击穿/雪崩及其解决方案
五种基于go的轻量级数据库的比较 本项目基于github上的开源项目badger-bench对五种基于go的轻量级数据库——badger、lmdb、boltdb、rocksdb,leveldb——进行比较。 项目原址: badger-bench 一、实验环境 本项目的运行环境为Ubuntu 9.3.0-17ubuntu1~2… 阅读更多 »五种基于go的轻量级数据库的比较
1. 缓存数据不一致 数据库的瓶颈是大家有目共睹的,高并发的环境下,很容易 I/O 锁死。当务之急,就是把常用的数据,给捞到速度更快的存储里去。 这个更快的存储,就有可能是分布式的,比如 Redis,也有可能是单机的,比如 Caffeine。 但一旦加入缓存,就不得不面对一个蛋疼的问题:数据的一致性。 数据不一致的问题,人世间多… 阅读更多 »缓存数据一致性问题(转载)
github下载慢或报错“The-remote-end-hung-up-unexpectedly”解决办法:该问题往往因为内部网络限制等因素导致。 因细节更新,欢迎访问本文源站链接:https://turbock79.cn/?p=173。 1.方法一 解决gitbub下载慢问题,可… 阅读更多 »github下载慢或报错“The-remote-end-hung-up-unexpectedly”解决办法
1. 数据同步问题 有很多情况下需要考虑线程安全问题,一个全局的变量如果有可能会被多个同时执行的线程去修改,那么对于这个变量的修改就需要有一种机制去保证值的正确性和一致性,这种机制普遍的做法就是加锁。其实也很好理解,和现实中一样,多个人同时修改一个东西,必须有一种机制来把多个人进行排队。计算机的世界中也是如此,多个线程乃至多个进… 阅读更多 »数据同步及锁
本文基于VMware虚拟机环境,详细请参考本文源站地址。 操作系统:CentOS7.6 Linux version 3.10.0-957.27.2.el7.x86_64 适用VPP版本:19.08-20.05,本文示例版本19.08 操作用户权限:root 系统驱动如果支持MSI-X,就无法使用驱动uio_pci_generic… 阅读更多 »编译安装VPP及运行
Go中Channel发送和接收操作指南 1. 前言 先来看一道面试题: 对已经关闭的 chan 进行读写,会怎么样?为什么? 在golang中channel属于较为核心的一个功能,尤其在go协程中,channel功能尤为重要;如果多个任务之间需要通信,可能就要用到通道(channel)。 2. Channel的定义 声明并初始化… 阅读更多 »Golang Channel发送和接收
1. 概述 添加行: df.loc[]以及df.append()两种方法 添加列: df[]和df.insert()两种方法 添加行列: concat()和reindex()两种方法 loc bug解决 2. 添加行 2.1. 采用loc[]方法 loc方法和iloc方法一样,可以索引DataFrame数据,一般是通过data.… 阅读更多 »Python pandas中DataFrame中增删行列
1. 引入numpy第三方库 首先我们引入numpy这个第三方库,如果有同学没安装numpy可在命令行中pip install numpy进行安装(Mac用户 sudo pip3 install numpy) 测试采用python版本3.7.0 64bit
1 |
import numpy as np |
在Go 1.11之后推出了依赖包管理工具Go Modules之后,Go项目可以在 GOPATH 之外的位置创建,当项目中仅使用了公有库作为依赖时,使用 go get 或 go mod 更新依赖一切如初,没有任何问题。 由于Go Modules默认使用代理去更新依赖,所以当使用了私有仓库作为依赖时,Go更新依赖的相关命令将不再可用… 阅读更多 »Go Mod引用私有库
1. 获取google代码protobuf
1 2 3 4 5 6 7 8 |
# 配置go 代理 go env -w GOPROXY="https://goproxy.cn,direct" # 下载protobuf代码到${GOPATH}/pkg/google.golang.org/protobuf go get google.golang.org/protobuf # 下载protobuf指定版本 go get google.golang.org/protobuf@v1.27.1 git clone https://ghproxy.com/https://google.golang.org/protobuf |
2. 根据名称获取pb并创建结构体
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
//"github.com/golang/protobuf/jsonpb" //老版本 //"github.com/golang/protobuf/proto" //老版本 "google.golang.org/protobuf/encoding/prototext" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" // ProtoWithName is used to marshall proto message data alongside the proto // message name. type ProtoWithName struct { ProtoMsgName string ProtoMsgData string } // proto.MarshalTextString(item) 老版本 "github.com/golang/protobuf/proto" // prototext.Marshal(item) 新版本 "google.golang.org/protobuf/encoding/prototext" // MarshalJSON marshalls proto message using the marshaller from jsonpb. // The jsonpb package produces a different output than the standard "encoding/json" // package, which does not operate correctly on protocol buffers. func (p *RecordedProtoMessage) MarshalJSON() ([]byte, error) { var ( msgName string msgData string err error ) if p != nil { msgName = string(proto.MessageName(p.Message)) msgbin, err := proto.Marshal(p.Message) if err != nil { return nil, err } msgData = string(msgbin) } pwn, err := json.Marshal(ProtoWithName{ ProtoMsgName: msgName, ProtoMsgData: msgData, }) if err != nil { return nil, err } return pwn, nil } // UnmarshalJSON un-marshalls proto message using the marshaller from jsonpb. // The jsonpb package produces a different output than the standard "encoding/json" // package, which does not operate correctly on protocol buffers. func (p *RecordedProtoMessage) UnmarshalJSON(data []byte) error { var pwn ProtoWithName if err := json.Unmarshal(data, &pwn); err != nil { return err } p.ProtoMsgName = pwn.ProtoMsgName if p.ProtoMsgName == "" { return nil } //msgType := proto.MessageType(pwn.ProtoMsgName) //老版本 // 获取full name对应的message ,如果不存在则返回error msgType, err1 := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(pwn.ProtoMsgName)) if err1 != nil { return err1 } if msgType == nil { return fmt.Errorf("unknown proto message: %s", p.ProtoMsgName) } //msg := reflect.New(msgType.Elem()).Interface().(proto.Message) //老版本 msg := msgType.New().Interface() var err error if len(pwn.ProtoMsgData) > 0 && pwn.ProtoMsgData[0] == '{' { //err = jsonpb.UnmarshalString(pwn.ProtoMsgData, msg) //老版本 err = proto.Unmarshal([]byte(pwn.ProtoMsgData), msg) //protojson } else { //err = proto.UnmarshalText(pwn.ProtoMsgData, msg) //老版本 err = prototext.Unmarshal([]byte(pwn.ProtoMsgData), msg) } if err != nil { return err } p.Message = msg return nil } |
3. AnyPb 转换 proto.Message 3.1. Marshal Any [crayon-628fe96c… 阅读更多 »Golang中protobuf版本升级
1. 错误:Failed to connect to github.com port 443: Connection refused 1.1. 解决方法
1 2 3 4 |
#查询ip地址,或nslookup等方式查询ip ping github.com #配置指定ip解析 vi /etc/hosts (添加下dns地址,做域名指定IP解析) |
1.2. 参考博文 https://blog.csdn.net/qq_45435600/article/det… 阅读更多 »git连接错误Connection refused
1.git clone 把远程库克隆到本地文件夹
1 2 3 4 5 6 7 8 9 10 11 12 |
git clone -b dev https://gitee.com/XXX/EmpManage //直接克隆远程dev分支到本地dev分支 //相当于如下操作 git clone https://gitee.com/XXX/XXXManage //克隆远程仓库主分支 cd XXXManage git status //查看当前状态 git branch -a //查看所有分支 //git branch -d dev //删除分区命令 git checkout -b dev //当前PC本地仓库创建一个新分区 git pull origin dev //拉取远程origin/dev分支到当前路径(git branch dev remotes/origin/dev) git checkout dev //切换到dev分支 |
2.编辑本地仓库文件并提交到本地信息库(git add ./git commit)
1 2 3 4 |
nano README.md //读取README.md文件中内容 ... git add . //git add --all //git add AAA.hpp bbb.cpp git commit -m "x修改信息" //提交当前状态到本地分支并附上修改信息 |
3.将本地库提交到远程Git服务器 [crayon-628fe9… 阅读更多 »Git深入理解-提交合并分支及回退