Redis Objects
In the previous article, we introduced the low-level data structures defined in Redis. Next, in this article, we will combine these with the objects provided by Redis to see how these data structures are used in practice. Redis primarily includes the following objects: strings, lists, hashes, sets, sorted sets, HyperLogLog, GEO, etc. This article will mainly cover how these objects are implemented. For their commands, you can refer to the official Redis documentation, which provides detaile...
Redis Data Structures
Redis, as a widely used in-memory database, has made many extreme optimizations at the code level to achieve better performance. An important part of this is the use of underlying data structures. Redis optimizes the usage of different structures based on data volume, data size, and other factors, thereby achieving better operational efficiency and memory usage. Redis’s core data structures include Simple Dynamic Strings, linked lists, dictionaries, skip lists, integer sets, and compressed li...
Design Patterns Cheatsheet
As everyone knows, design patterns are an extremely important discipline for programmers. However, because design patterns cover such a broad scope and involve many abstract concepts, they can be quite difficult to master. The best way to learn design patterns is to combine them with practical experience. Every time you work on a requirement — especially complex ones, or when you detect signs of smelly code — you can flip through the design patterns to see which ones might apply. Therefore, I...
Reflections on a Programmer's Career — My Understanding of the Programming Profession
Over the years of working, I’ve been constantly thinking about what a programmer actually does. As I’ve gained more experience, my understanding has continuously evolved. Writing this article now serves two purposes: sharing my thoughts, and leaving a record to revisit in a couple of years to see how my understanding has further changed. The Essence of Programming as a CareerI want to discuss this from two perspectives. First, from the work itself — in my view, a programmer’s work falls int...
Troubleshooting MySQL Batch Operations in Java: Why Batches Sometimes Don't Work
As is well known, using batch operations with MySQL can significantly improve performance when dealing with large datasets. However, when using MySQL in Java, certain details must be carefully handled; otherwise, batch operations may not actually take effect, and you won’t benefit from the performance gains of batching. The ProblemRecently, I noticed that the performance profile of a particular SQL query was abnormally slow — inserting several thousand records in batch was taking on the ord...
Unit Testing Best Practices: Practical Experience and Guidelines
A while ago, when I was trying to improve the unit tests for a project, I realized that I never had a particularly clear understanding of how to write unit tests. So I looked up some materials, and in the process discovered that everyone’s perspectives are quite different. Every article I read updated my own understanding. This article combines others’ viewpoints with my own practical experience to summarize what I currently believe to be correct. It probably won’t be the most definitive answ...
About RocketMQ's readQueue and writeQueue
RocketMQ’s MessageQueue has a unique design: it splits a queue into readQueueNums (read queue count) and writeQueueNums (write queue count). In the vast majority of cases, these two values must be equal — if they diverge, serious problems arise. So why separate them? The answer lies in smooth scaling. What is a MessageQueue?In RocketMQ, a Topic is a logical category for messages, while a MessageQueue is the physical shard of a Topic, similar to Kafka’s Partition. A key constraint: the numbe...
A Powerful Tool for Data Analytics: Introduction to ClickHouse
ClickHouse is an open-source database for real-time data analytics developed by Yandex, initially used in multiple data analytics projects internally at Yandex. To introduce ClickHouse, we first need to introduce Yandex. ClickHouse’s emergence is closely related to Yandex’s business needs. Yandex is Russia’s largest search engine, with many data analytics projects. The largest of these by data volume is Yandex.Metrica, a website analytics service similar to Baidu Analytics, with data volume s...
Converting Between Uppercase and Lowercase Using Bitwise Operations
Bitwise operations are among the most fundamental and efficient operations in computer science. Today, let’s explore a classic application: converting between uppercase and lowercase letters with a single line of code. Why Use Bitwise Operations for Case Conversion?Your first reaction might be: doesn’t Java already have Character.toUpperCase() and Character.toLowerCase()? Why reinvent the wheel? Indeed, 99% of the time you should use the standard library. But understanding this trick has se...
ActiveMQ Multi-threaded Consumption - Different Approaches
Problem ScenarioIn a previous article, I introduced the basic syntax for using ActiveMQ on the client side. It is worth noting the consumer side: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 public void consume() throws JMSException { ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(); cf.setBrokerURL("tcp://localhost:61616"); Connection connection = cf.createConnection(); connection.start(...













