Memory-augmented neural network (MANN) has received increasing attention as a promising approach to achieve lifelong on-device learning, of which implementation of the explicit memory is vital. Ternary content addressable memory (CAM) with the capacity of computing Hamming distance has been designed to accelerate the explicit memory by harnessing the in-memory-computing capability. Given that the memory states in the biological brain are high-precision and the processing function is much more complex than Hamming distance, therefore, developing multi-bit CAM with a more powerful distance function is an effective path to imitate the sophisticated capabilities of our brain and move towards advanced lifelong machine intelligence. In this work, a novel CAM cell with quadratic code is proposed and a 1Mb Flash-based multi-bit-storage and ternary-search CAM chip capable of computing Euclidean (L2) distance is fabricated. Compared with traditional ternary CAM with Hamming distance, the latency and energy are significantly reduced by 5.3 folds and 46.6 folds, respectively, at the same recognition accuracy of MANN on Omniglot dataset. On the other hand, when the word widths of CAM are identical, the recognition accuracy of the proposed CAM is increased by 8.5% on average for different few-shot learning tasks compared with ternary CAM. Besides, the measured data of the fabricated CAM chip show that the recognition accuracy has slight degradation (<1%) even after baking for 1e5 s at 200℃, demonstrating the robust stability to the disturbance of environmental factors. Performance evaluation indicates a 471-fold reduction in search latency and 1267-fold reduction in search energy compared with graphics processing unit (GPU) for search operation. The proposed robust and energy-efficient CAM provides a promising solution to implement lifelong on-device machine intelligence.