Category: development

Ubiquitous Client for Redis Server: Netcat

Forget about redis-cli. Just use nc bash-5.0# nc -v 10.x.x.x 6379 10.x.x.x (10.x.x.x:6379) open select 14 +OK What is ncat? NAME nc — arbitrary TCP and UDP connections and listens SYNOPSIS nc [-46AcDCdhklnrtUuvz] [-b boundif] [-i interval] [-p source_port] [-s source_ip_address] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [–apple-delegate-pid […]

SIngle Thread LRUCache in C++

#include <iostream> #include <list> #include <unordered_map> using namespace std; size_t capacity; class LRUCache { public: bool Lookup(int key, int *price) { auto it = hash_table.find(key); if (it == hash_table.end()) { return false; } *price = it->second.second; // update the key in the queue MoveToFront(key, it); return true; } […]