Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:A616567126 GPT WEB JAVA Redis Cache

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Caching
Last Updated 2026-10-13 18:00 GMT

Overview

Redis 7 with Redisson 3.15.5 distributed lock support, used for caching, task queues, JWT token validation, and API access token storage.

Description

This environment provides the in-memory data layer for GPT-WEB-JAVA. Redis is used for multiple purposes: (1) caching system config and payment config objects loaded at startup, (2) JWT token storage with 7-day TTL for authentication validation, (3) SD image generation queue via Redis List operations, (4) Baidu API access token caching with 29-day TTL, (5) email verification code storage, and (6) user client type tracking. Redisson 3.15.5 provides distributed locking capabilities. The RedisTemplate is configured with Jackson2JsonRedisSerializer for values and StringRedisSerializer for keys. Jedis connection pool is configured with max 1000 active connections, max 100 idle, and configurable timeout.

Usage

Use this environment for all caching, queuing, and distributed lock operations. Required by JWT authentication (token storage), SD image generation (Redis-based queue), GPT key pool initialization (config caching), Baidu content moderation (access token caching), and Discord task management.

System Requirements

Category Requirement Notes
OS Any OS supporting Redis 7 Linux recommended
Hardware 512MB+ RAM for Redis instance Stores cached configs, tokens, queues
Disk Minimal (Redis is in-memory) Only for AOF/RDB persistence if enabled
Network Redis accessible on configured host:port Dev: 127.0.0.1:6379, Prod: 127.0.0.1:6380

Dependencies

System Packages

  • `redis-server` = 7.x

Java Packages (Maven)

  • `spring-boot-starter-data-redis` = 2.3.5.RELEASE
  • `redisson` = 3.15.5

Credentials

The following must be configured in `application-dev.yml` or `application-prod.yml`:

  • `spring.redis.host`: Redis server hostname
  • `spring.redis.port`: Redis server port (dev: 6379, prod: 6380)
  • `spring.redis.password`: Redis password (dev: `simshen`, prod: `redis-ssp`)
  • `spring.redis.database`: Redis database index (1)

Quick Install

# Redis dependencies are declared in pom.xml:
# spring-boot-starter-data-redis:2.3.5.RELEASE
# redisson:3.15.5

# Ensure Redis 7 is running:
redis-server --port 6379 --requirepass "your-password"

Code Evidence

Redis configuration from `application-dev.yml:20-31`:

  redis:
    host: 127.0.0.1
    port: 6379
    database: 1
    password: simshen
    jedis:
      pool:
        max-idle: 100
        min-idle: 1
        max-active: 1000
        max-wait: -1
    timeout: 10000s

RedisTemplate serialization config from `RedisConfig.java:27-48`:

Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance,
    ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(jackson2JsonRedisSerializer);

Redis queue operations from `QueueUtil.java:22-27`:

public void addUserToQueue(String value) {
    if(getCurrentQueueLength() > CommonConst.QUEUE_SIZE){
        throw new E("队列已满请等待");
    }
    redisTemplate.opsForList().rightPush(QUEUE_KEY, value);
}

Common Errors

Error Message Cause Solution
`Cannot get Jedis connection` Redis not running or unreachable Verify Redis is running on configured host:port
`WRONGPASS Authentication failed` Wrong password in application yml Check `spring.redis.password` matches Redis config
`RedisConnectionException` Network issue or firewall blocking port Ensure port 6379/6380 is accessible
`ClassCastException on deserialization` Jackson type info missing in cached object Ensure all cached objects are serializable with Jackson2JsonRedisSerializer

Compatibility Notes

  • Redis 6.x: Compatible; no Redis 7-specific features are used.
  • Redisson version: 3.15.5 is pinned; upgrading requires testing distributed lock behavior.
  • Database index: Uses database 1; ensure no other application uses the same Redis database index.
  • Timeout: Dev profile uses 10000s timeout (very long); prod uses 100s. Adjust per deployment needs.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment