isHuPei's Development and Environment Guides

website·Indexed 30 days ago

https://ishupei.github.io

A collection of technical guides covering environment setup for JDK 1.8, Maven, MySQL 5.7, Redis, and NodeJs. Includes Java fundamentals such as I/O, NIO, reflection, annotations, and HashMap, as well as JVM constant pool details and Redis persistence mechanisms (RDB, AOF).

Tokens
11.4K
Snippets
18
Records
75
Agent score
74%

What's inside isHuPei Knowledge Base

  1. Overview of the Vue.js Frontend Stack

    The frontend is built using Vue.js, a progressive framework for building user interfaces based on the MVVM design pattern.

    • Vue 2 vs Vue 3: Vue 2 uses the Options API, while Vue 3 introduces the Composition API, differing in how data binding and monitoring are implemented.
    • ElementUI: A Vue-based UI component library developed by Ele.me, used for rapidly implementing UI elements via pre-built components.
    • Axios: A promise-based HTTP client used to send asynchronous network requests from the frontend to the backend.
  2. Overview of Redis Data Types

    Redis provides five core data types and several extended types built upon them:

    Core Data Types:

    1. String: Binary-safe strings containing text, integers, or floats. Supports increment/decrement operations.
    2. Hash: Collections of field-value pairs, ideal for storing objects.
    3. List: Ordered lists of strings based on doubly linked lists; usable as stacks or queues.
    4. Set: Unordered collections of unique strings; supports set operations (intersection, union, difference).
    5. Sorted Set (ZSet): Unique strings associated with a score, sorted by that score. Ideal for leaderboards.

    Extended Data Types:

    1. Bitmaps: Specialized Strings for bit-level operations, used for binary state tracking (e.g., user check-ins).
    2. HyperLogLogs: Specialized Strings for approximating the cardinality of a set with <1% error, highly memory-efficient.
    3. Streams: Enhanced Lists providing a full message queue with persistence, consumer groups, and acknowledgments.
    4. Geo: Used for storing and querying geographical location information.
  3. Overview of Java Collections Framework

    Java collections (containers) are primarily derived from two top-level interfaces:

    1. Collection: Used for storing single elements. Its main sub-interfaces include List (ordered, allows duplicates), Set (no duplicates), and Queue (ordered by specific rules, allows duplicates).
    2. Map: Used for storing key-value pairs.
  4. Overview of the Spring Boot Backend Stack

    The backend utilizes the Spring ecosystem for enterprise-grade Java development:

    • Spring Boot: A rapid configuration scaffold that follows the 'convention over configuration' philosophy. It embeds web servers (like Tomcat or Jetty) for out-of-the-box execution.
    • Spring Security: A powerful security framework used for authentication and authorization. It operates as a chain of filters (Responsibility Chain pattern).
    • MyBatis: A persistence layer framework that simplifies JDBC operations and optimizes data mapping and result set retrieval.
    • Maven: A project management and build tool used for dependency management via pom.xml and packaging projects into JAR or WAR files.
  5. Understand the HTTP Request-Response Cycle

    HTTP (Hyper Text Transfer Protocol) is a request-response protocol running over TCP. A client (e.g., a web browser or mobile app) initiates an HTTP Request, and the server (the provider of the resource) returns an HTTP Response. The basic flow is: Client sends request $\rightarrow$ Server processes request $\rightarrow$ Server returns response $\rightarrow$ Client renders the content.
  6. Implement Authentication and Caching with Redis and JWT

    The system uses Redis for high-performance data storage and JWT for secure client authentication.

    • Redis: A NoSQL in-memory database used for storing volatile or high-access data such as verification codes and data dictionaries.
    • JWT (JSON Web Token): A standard for securely transmitting information as a JSON object.
      • Workflow: Upon successful login, the server generates a signed token (JWT) and returns it to the client. The client stores this token and includes it in the header of subsequent requests. The server verifies the token to authenticate the client before processing the request.
  7. Reasons for Redis High Performance

    Redis achieves extreme performance through several architectural choices:

    1. In-Memory Storage: Avoids disk I/O bottlenecks by operating directly on RAM.
    2. Single-Threaded Architecture: Eliminates context switching and lock contention, ensuring atomic operations.
    3. Optimized Data Structures: Uses specialized implementations like SDS (Simple Dynamic String) for O(1) length retrieval and binary safety, and Skip Lists for ZSets to provide O(log N) range queries.
    4. I/O Multiplexing: Uses epoll to handle thousands of concurrent connections efficiently within a single thread.
    5. Incremental Rehash: Prevents blocking during hash table expansion.
  8. Understand Java Reflection and its trade-offs

    Java Reflection is the ability to dynamically acquire class information and manipulate classes or objects (methods, properties) at runtime. It allows code to handle types that are unknown at compile time, making it the foundation for most general-purpose Java frameworks.

    Advantages:

    • Flexibility: Enables dynamic loading of classes, object creation, and method invocation based on configuration or user input.
    • Framework Foundation: Essential for implementing Dependency Injection (DI), Aspect-Oriented Programming (AOP), and Object-Relational Mapping (ORM).
    • Decoupling: Facilitates the creation of generic utilities like object copiers and serializers.

    Disadvantages:

    • Performance Overhead: Slower than direct calls due to dynamic type resolution and limited JIT optimization.
    • Security Risks: Can bypass access modifiers (e.g., accessing private fields), breaking encapsulation.
    • Maintainability: Increases code complexity; errors often surface at runtime rather than compile time.
  9. Understand Redis key expiration strategies

    Redis uses a combination of two strategies to delete expired keys:

    1. Lazy Expiration: A key is checked and deleted only when a client attempts to access it. This is CPU-efficient but can lead to memory waste if expired keys are never accessed.
    2. Periodic Expiration: Redis randomly samples a batch of keys with TTLs at a fixed interval (e.g., 10Hz) and deletes those that have expired. This prevents memory leaks from unaccessed expired keys while limiting CPU impact by capping the execution time of each cycle.
  10. Implement security and authorization with Apache Shiro

    Apache Shiro is a Java-based security framework used for authentication, authorization, encryption, and session management. It encapsulates security logic and exposes a simplified API for managing user permissions.
  11. Understand HTTP Request and Response basics

    HTTP (Hyper Text Transfer Protocol) is a request-response protocol running over TCP. A client (e.g., browser) initiates an HTTP Request, and the server returns an HTTP Response.

    HTTP Request Components:

    • Method: Defines the action (e.g., GET for retrieving content, POST for submitting data).
    • URL: The address of the resource.
    • Headers: Metadata (e.g., content type, client device info).
    • Body: Optional data sent to the server (e.g., login credentials).

    HTTP Response Components:

    • Status Code: Indicates the result (e.g., 200 OK for success, 404 Not Found for missing resources, 500 Server Error for server-side failures).
    • Headers: Metadata about the response.
    • Body: The actual content (e.g., HTML, JSON, images).

    Observation Tip: Use Browser Developer Tools (F12) -> Network tab to inspect real-time HTTP requests, headers, and status codes.

  12. Understand the role of Tokens in authentication

    A token is an encrypted string generated by the server that acts as a client identifier. After a user's initial login, the server returns a token to the browser. For subsequent requests, the client provides this token instead of re-sending the username and password, allowing the server to verify the identity and authorize the operation.