• Redis advanced application: redis + Lua script to realize composite operation


    1、 Introduction Redis is a high-performance key value database, which overcomes the shortage of memcached key / value storage to a great extent. In some scenarios, it is a good supplement to relational database. Due to its ultra-high performance and rich data structure, redis has become the preferred key value storage system in current architecture […]

  • Best of the year sync.Map Detailed explanation


    In our work, we often encounter the situation that the map is read and written concurrently, which results in the panic. Why do we have the panic when reading and writing the map concurrently? Because in the case of concurrent read and write, the data in the map will be written disorderly, and thenGarbage in, […]

  • CAS of Java multithreading


    CAS (Compare and Swap) CAS has three operands: memory value m, expected value E, and update value U. If and only if the memory value m and the expected value E are equal, change the memory value m to u, otherwise nothing will be done. 1. Application scenarios of CAS CAS is only suitable for […]

  • Since synchronized is omnipotent, why volatile is needed?


    synchronizedandvolatileTwo keywords are often used in Java Concurrent Programming. We knowsynchronizedIt can ensure that there will be no atomicity, visibility and ordering problems in concurrent programming, while volatile can only guarantee visibility and orderliness,Now that we have itsynchronizedWhy do we need itvolatile? In order to solve the atomicity, visibility and orderliness in multithreading, Java provides […]

  • Volatile keyword for Java concurrency


    introduction When it comes to multithreading, I think the most important thing is to understand the concept of a critical region. For example, there are 1 girl (critical area) and 49 boys (thread) in a class. The goal of boys is to have a girl, which means there will be competition (thread safety). It is […]

  • Atom installation and configuration C / C + + detailed tutorial


    Atom (an open source code editor) is a cross platform text editor specially launched by GitHub for programmers. It has a simple and intuitive graphical user interface, and has many interesting features: it supports CSS, HTML, JavaScript and other web programming languages, and also supports popular programming languages such as C, C + +, Java, […]

  • [6. C + + basics] – lock


    The meaning of lock Atomicity + visibilityAt the same time, only one thread executes the code in the lock + read in the lock. The code before the lock is executed and the write is visible before the lock is released atom operation The atoms in the kernel are implemented by atomic instructions https://code.woboq.org/linux/…The following […]

  • [cartoon] CAS principle analysis! No lock atomic class can also solve the concurrency problem!


    This article is from WeChat official account. In the cartoon concurrent programming system blog post, we talked about n articles about lock. Indeed, lock is the master key to solve concurrency problem, but can only lock solve concurrency problem? Today, we will present a big boss: CAS lock free algorithm, which is the core of […]

  • Implement a redis distributed lock


    preface In our daily development, we will inevitably encounter the situation of locking. For example, after deducting the product inventory, the inventory should be taken from the database first, and then the inventory should be subtracted. This wave of operations obviously does not conform to atomicity. If the code block is not locked, it is […]

  • Tomcat servlet read request parameters


    Read querystring on URL org/apache/tomcat/embed/tomcat-embed-core/8.0.33/tomcat-embed-core-8.0.33-sources.jar!/org/apache/catalina/core/ApplicationDispatcher.java private void doDispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException private void doForward(ServletRequest request, ServletResponse response) throws ServletException, IOException private void doInclude(ServletRequest request, ServletResponse response) throws ServletException, IOException Here’s dodispatch private void doDispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException { // Set up to handle the specified request and response State […]

  • PHP regular expression function parsing and regular expression basic syntax


    1、 PHP regular expression function analysis preg_ match();preg_ match_ All (); form validation, etc //Validity of email address – preg_ Match (), the matching result can be regarded as a bool value preg_ Replace(); filtering of illegal words //f**k 2、 Regular expression basic syntax Tools for testing regular expressions At noon, it’s better to convert […]

  • Regular expressions of PHP basic series (1)


    Definition of regular expression Regular expression is a kind of custom syntax rule to describe character arrangement pattern.Regular expressions are also called pattern expressions because they have a very complete syntax system that can write patterns and provide a flexible and intuitive string processing method. Characteristics of regular expressions Regular expressions are not unique to […]