auto commit
This commit is contained in:
parent
64b26639c8
commit
137710c645
@ -1,16 +0,0 @@
|
||||
<!-- GFM-TOC -->
|
||||
* [0. 进程内存空间中,堆和栈的区别](#0-进程内存空间中,堆和栈的区别)
|
||||
<!-- GFM-TOC -->
|
||||
|
||||
|
||||
# 0. 进程内存空间中,堆和栈的区别
|
||||
|
||||
> C++
|
||||
|
||||
堆:动态、malloc()、new、链式分配、向上生长;栈:函数调用、编译器分配回收、向下生长。
|
||||
|
||||
https://www.cnblogs.com/sunziying/p/6510030.html
|
||||
|
||||
By @CyC
|
||||
|
||||
---
|
@ -70,7 +70,7 @@
|
||||
|
||||
接收端能够从消息队列成功消费一次消息。
|
||||
|
||||
实现方法:
|
||||
两种实现方法:
|
||||
|
||||
- 保证接收端处理消息的业务逻辑具有幂等性:只要具有幂等性,那么消费多少次消息,最后处理的结果都是一样的。
|
||||
- 保证消息具有唯一编号,并使用一张日志表来记录已经消费的消息编号。
|
||||
|
17
notes/缓存.md
17
notes/缓存.md
@ -58,6 +58,7 @@ public class LRU<K, V> implements Iterable<K> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LRU(int maxSize) {
|
||||
|
||||
this.maxSize = maxSize;
|
||||
@ -70,6 +71,7 @@ public class LRU<K, V> implements Iterable<K> {
|
||||
tail.pre = head;
|
||||
}
|
||||
|
||||
|
||||
public V get(K key) {
|
||||
|
||||
if (!map.containsKey(key)) {
|
||||
@ -83,6 +85,7 @@ public class LRU<K, V> implements Iterable<K> {
|
||||
return node.v;
|
||||
}
|
||||
|
||||
|
||||
public void put(K key, V value) {
|
||||
|
||||
if (map.containsKey(key)) {
|
||||
@ -100,30 +103,34 @@ public class LRU<K, V> implements Iterable<K> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void unlink(Node node) {
|
||||
Node pre = node.pre;
|
||||
node.pre = node.next;
|
||||
node.next = pre;
|
||||
Node next = node.next;
|
||||
pre.next = next;
|
||||
next.pre = pre;
|
||||
}
|
||||
|
||||
|
||||
private void appendHead(Node node) {
|
||||
node.next = head.next;
|
||||
node.pre = head;
|
||||
head.next = node;
|
||||
}
|
||||
|
||||
|
||||
private Node removeTail() {
|
||||
Node node = tail.pre;
|
||||
node.pre = tail;
|
||||
tail.pre = node.pre;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<K> iterator() {
|
||||
|
||||
return new Iterator<K>() {
|
||||
|
||||
private Node cur = head.next;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return cur != tail;
|
||||
|
Loading…
x
Reference in New Issue
Block a user