auto commit

This commit is contained in:
CyC2018 2018-09-03 22:34:58 +08:00
parent 64b26639c8
commit 137710c645
3 changed files with 13 additions and 22 deletions

View File

@ -1,16 +0,0 @@
<!-- GFM-TOC -->
* [0. 进程内存空间中,堆和栈的区别](#0-进程内存空间中,堆和栈的区别)
<!-- GFM-TOC -->
# 0. 进程内存空间中,堆和栈的区别
> C++
动态、malloc()、new、链式分配、向上生长函数调用、编译器分配回收、向下生长。
https://www.cnblogs.com/sunziying/p/6510030.html
By @CyC
---

View File

@ -70,7 +70,7 @@
接收端能够从消息队列成功消费一次消息。
实现方法:
两种实现方法:
- 保证接收端处理消息的业务逻辑具有幂等性:只要具有幂等性,那么消费多少次消息,最后处理的结果都是一样的。
- 保证消息具有唯一编号,并使用一张日志表来记录已经消费的消息编号。

View File

@ -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;