![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cs
文章平均质量分 72
quick刀斩乱麻
follow for more
展开
-
分布式事务
在2PC中,participant在发送PREPARED消息后,收到coodinator最终决定(COMMIT / ABORT)前,无法单独决定要提交还是回滚事务,如果此时coodinator宕机,participant的事务状态无法确定,导致阻塞。以下单扣库存为例,Try 阶段占库存,Confirm阶段实际扣库存,如果库存扣减失败Cancel阶段进行回滚,释放库存。TCC不存在资源阻塞的问题,因为每个方法都直接进行事务的提交,一旦出现异常通过则Cancel进行回滚补偿,这也就是常说的。原创 2022-11-09 14:25:40 · 256 阅读 · 0 评论 -
Java的线程状态
线程状态原创 2022-10-27 16:52:26 · 364 阅读 · 0 评论 -
Java的NIO
Linux的五种IO模型阻塞IO:应用进程从发起IO系统调用,至内核空间中的数据就绪,这个期间处于阻塞状态。非阻塞IO:应用进程发起IO系统调用后立刻返回。应用进程可以不断(轮询)发起IO系统调用,直至数据就绪,再将数据从内核空间拷贝到用户空间进行数据处理。(在拷贝数据的过程,进程仍然属于阻塞状态)。优点是进程发起I/O操作时,不会因为数据还没就绪而阻塞。缺点是增大了响应延迟,因为每过一段时间才会发起系统调用检查数据是否就绪,而任务可能在两次轮询之间的时间完成,这会导致整体数据吞吐量的降低;尤其是在原创 2022-02-04 15:23:59 · 614 阅读 · 0 评论 -
Linux的IO
操作系统的IO分为:网络IO、磁盘IO、内存IO等,我们通常考虑的是网络IO和磁盘IO。网络IO网络IO本质是socket读取sendfile普通的网络传输步骤是:操作系统将数据从磁盘复制到操作系统内核的页缓存中,应用将数据从内核缓存复制到应用缓存中,然后应用将数据写回内核的Socket缓存中,最后操作系统将数据从Socket缓存区复制到网卡缓存,然后将其通过网络发出。而通过sendfile磁盘IO磁盘IO的访问方式如下:缓存IO(标准IO)大多数文件系统的IO操作默原创 2022-02-03 20:23:37 · 874 阅读 · 0 评论 -
FP的范畴论
CategoryA category consists of: objects, morphisms(or arrows / maps) between the objects.for ever three the following axioms hold: associativity: if f: a -> b, g: b -> c, h: c -> d then h (gf) = (hg) f; identity: for every object, there ex原创 2021-12-05 15:46:26 · 256 阅读 · 0 评论 -
Linux的常用命令
The differences betweensh,sourceand./:source foo.sh ( . foo.sh):read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename (so attributes and environment of the cu...原创 2021-03-22 13:50:10 · 146 阅读 · 1 评论 -
Linux的基础知识
DOS:disk operating system. DOS systemuse a command-line interface. 是Windows系统之前的一个操作系统名称,属于单用户单任务式的,特点通常是黑底白字,用户全靠键盘输入命令来完成所有工作。之后Windows诞生了,属于多用户多任务式的(系统名称都是多窗口),初期当然还得使DOS系统可用,再之后专门开辟个cmd窗口来模仿DOS界面及大多数的命令,也称为命令行,这就是cmd命令行的诞生。CMD:操作系统可以分成kernel和s..原创 2021-03-22 13:49:27 · 68 阅读 · 0 评论 -
postgreSQL的哈希索引
Hash Table (Hash Map)哈希表是根据key直接进行访问的数据结构(这一结构的实现通常采用数组),它通过把关键码值映射(这个映射函数叫做散列函数)到表中一个位置来访问记录,以加快查找的速度。ahash table(hash map) is a data structure that implements an associative array abstract data type,a structure that can map keys to values. A has...原创 2021-08-07 17:24:57 · 284 阅读 · 0 评论 -
Go的设计模式
工厂模式package mainimport "fmt"// 产品接口type Shape interface { draw()}//具体产品type Rectangle struct {}func (Rectangle) draw() { fmt.Println("Draw Rectangle")}type Square struct {}func (Square) draw() { fmt.Println("Draw Square")}type Ci原创 2021-07-12 17:41:06 · 70 阅读 · 0 评论 -
传值还是传引用?
堆与栈在数据结构中:堆(heap)是一个可以被看作一棵完全二叉树的数组对象;栈(堆栈/stack)是先进后出的线性表。堆:动态分配内存的一块区域,一般由程序员手动分配,比如Java中的new、C/C++中的malloc等,都是将创建的对象或内存块放置在堆中。栈:由编译器自动分配释放,用于存放函数的参数值,局部变量。关系:对于Java,基本类型直接存储在栈上,引用类型则是值(对象)存储在堆上,对对象的引用存储在栈上。 修改引用的值,即让引用指向其它对象;而访问及修改堆上的对象: 在C/原创 2021-05-08 10:41:07 · 135 阅读 · 0 评论 -
python的设计模式
创建型模式单例模式 (懒汉式)这种模式涉及到一个单一的类,该类负责创建自己的对象,同时确保只有单个对象被创建;该类提供了一种访问其唯一的对象的方式,可以直接访问,不需要实例化该类的对象。class SingletonObject: def __new__(cls): if not hasattr(SingletonObject,"__instance"): SingletonObject.__instance = super().__new__(原创 2021-01-06 16:10:25 · 119 阅读 · 0 评论 -
COMPILE TIME AND RUNTIME
Compile time: the time at which the source code is converted into an executed code.(when the program is compiled)Runtime: the time at which teh executable code is started running.(when the program executes)Compile-time errors:syntax error: not ...原创 2020-11-05 15:19:43 · 163 阅读 · 0 评论 -
函数式编程
a programming paradigm where programs are constructed by applying and composing functionsFirst-class functions (higher-order functions)enable curryingPure functionsno side-effects:the result is constant with respect to that argument list (referent..原创 2020-10-29 12:37:43 · 115 阅读 · 0 评论