C++使用链表实现key-value存储,并且实现LRU策略
1单链表长度不超过LIMIT2如果长度满,采用LRU(最旧记录丢弃)策略set时往单链表的尾部插入数据,每次get时将get到的节点移动到链表尾部,因此链表尾部数据为最新数据,依次往前,链表头部为最旧数据。代码如下#include <string>#include <iostream>using namespace std;struct ListNode{ string key; string value; ListNode* next;