Skip to content

Commit 137710c

Browse files
committed
auto commit
1 parent 64b2663 commit 137710c

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

notes/CyC 学习交流群 问题汇总.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

notes/消息队列.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
接收端能够从消息队列成功消费一次消息。
7272

73-
实现方法
73+
两种实现方法
7474

7575
- 保证接收端处理消息的业务逻辑具有幂等性:只要具有幂等性,那么消费多少次消息,最后处理的结果都是一样的。
7676
- 保证消息具有唯一编号,并使用一张日志表来记录已经消费的消息编号。

notes/缓存.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class LRU<K, V> implements Iterable<K> {
5858
}
5959
}
6060

61+
6162
public LRU(int maxSize) {
6263

6364
this.maxSize = maxSize;
@@ -70,6 +71,7 @@ public class LRU<K, V> implements Iterable<K> {
7071
tail.pre = head;
7172
}
7273

74+
7375
public V get(K key) {
7476

7577
if (!map.containsKey(key)) {
@@ -83,6 +85,7 @@ public class LRU<K, V> implements Iterable<K> {
8385
return node.v;
8486
}
8587

88+
8689
public void put(K key, V value) {
8790

8891
if (map.containsKey(key)) {
@@ -100,30 +103,34 @@ public class LRU<K, V> implements Iterable<K> {
100103
}
101104
}
102105

106+
103107
private void unlink(Node node) {
104108
Node pre = node.pre;
105-
node.pre = node.next;
106-
node.next = pre;
109+
Node next = node.next;
110+
pre.next = next;
111+
next.pre = pre;
107112
}
108113

114+
109115
private void appendHead(Node node) {
110116
node.next = head.next;
117+
node.pre = head;
111118
head.next = node;
112119
}
113120

121+
114122
private Node removeTail() {
115123
Node node = tail.pre;
116-
node.pre = tail;
124+
tail.pre = node.pre;
117125
return node;
118126
}
119127

128+
120129
@Override
121130
public Iterator<K> iterator() {
122131

123132
return new Iterator<K>() {
124-
125133
private Node cur = head.next;
126-
127134
@Override
128135
public boolean hasNext() {
129136
return cur != tail;

0 commit comments

Comments
 (0)