Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

spring-data-redisspring 数据 Redis

Agent Skill

用于辅助 Java 项目开发、面向对象设计、Spring 生态、Maven 或 Gradle 依赖和后端工程实践。它适合让 Agent 分析类结构、设计接口、整理服务分层、生成测试或检查常见代码坏味道。使用时需要结合项目已有架构、包结构和依赖版本,不应只按通用教程改代码;涉及数据库、事务、并发或框架配置时,应先确认运行环境和回归测试范围。

总安装

706

周安装

30

GitHub Stars

12

下载量

247
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:spring-data-redis(spring 数据 Redis)
来源仓库:https://github.com/claude-dev-suite/claude-dev-suite
仓库路径:skills/spring-data-redis
安装命令:
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill spring-data-redis
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/claude-dev-suite/claude-dev-suite --skill spring-data-redis

简介

为 Spring Boot 应用提供 Redis 缓存与分布式会话管理能力。

  • 常用于会话共享、热点数据缓存或消息队列中间件集成。
  • 支持 String、Hash、List 等多种数据结构的原子操作封装。
  • 需配置连接池参数并考虑持久化策略,避免缓存穿透问题。
  • 安装方式采用 GitHub 仓库克隆方式。spring-data-redis 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Spring Data Redis - Quick Reference

Full Reference: See advanced.md for hash/list/set operations, sorted sets, @RedisHash repository pattern, pub/sub configuration, and distributed lock patterns.
Deep Knowledge: Use mcp__documentation__fetch_docs with technology: spring-data-redis for comprehensive documentation.

Dependencies

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- For reactive -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
</dependency>

Configuration

spring:
  data:
    redis:
      host: localhost
      port: 6379
      password: ${REDIS_PASSWORD:}
      database: 0
      timeout: 2000ms
      lettuce:
        pool:
          max-active: 8
          max-idle: 8
          min-idle: 2

  cache:
    type: redis
    redis:
      time-to-live: 3600000  # 1 hour
      cache-null-values: false
      key-prefix: "myapp:"

RedisTemplate Configuration

@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        template.setConnectionFactory(connectionFactory);

        Jackson2JsonRedisSerializer<Object> jsonSerializer =
            new Jackson2JsonRedisSerializer<>(Object.class);

        template.setKeySerializer(new StringRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());
        template.setValueSerializer(jsonSerializer);
        template.setHashValueSerializer(jsonSerializer);

        template.afterPropertiesSet();
        return template;
    }
}

Basic String Operations

@Service
@RequiredArgsConstructor
public class RedisService {

    private final RedisTemplate<String, Object> redisTemplate;

    public void set(String key, Object value, Duration ttl) {
        redisTemplate.opsForValue().set(key, value, ttl);
    }

    public Object get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    public boolean setIfAbsent(String key, Object value, Duration ttl) {
        return Boolean.TRUE.equals(
            redisTemplate.opsForValue().setIfAbsent(key, value, ttl));
    }

    public Long increment(String key) {
        return redisTemplate.opsForValue().increment(key);
    }

    public void delete(String key) {
        redisTemplate.delete(key);
    }
}

Spring Cache Integration

@SpringBootApplication
@EnableCaching
public class Application { }

@Configuration
@EnableCaching
public class CacheConfig {

    @Bean
    public RedisCacheManager cacheManager(RedisConnectionFactory connectionFactory) {
        RedisCacheConfiguration defaultConfig = RedisCacheConfiguration.defaultCacheConfig()
            .entryTtl(Duration.ofMinutes(30))
            .disableCachingNullValues()
            .serializeKeysWith(RedisSerializationContext.SerializationPair
                .fromSerializer(new StringRedisSerializer()))
            .serializeValuesWith(RedisSerializationContext.SerializationPair
                .fromSerializer(new GenericJackson2JsonRedisSerializer()));

        Map<String, RedisCacheConfiguration> cacheConfigs = Map.of(
            "users", defaultConfig.entryTtl(Duration.ofHours(1)),
            "products", defaultConfig.entryTtl(Duration.ofMinutes(15))
        );

        return RedisCacheManager.builder(connectionFactory)
            .cacheDefaults(defaultConfig)
            .withInitialCacheConfigurations(cacheConfigs)
            .build();
    }
}

Cache Annotations

@Service
public class UserService {

    @Cacheable(value = "users", key = "#id")
    public User getUserById(Long id) {
        return userRepository.findById(id).orElse(null);
    }

    @CachePut(value = "users", key = "#user.id")
    public User updateUser(User user) {
        return userRepository.save(user);
    }

    @CacheEvict(value = "users", key = "#id")
    public void deleteUser(Long id) {
        userRepository.deleteById(id);
    }

    @CacheEvict(value = "users", allEntries = true)
    public void clearUserCache() { }
}

When NOT to Use This Skill

  • Raw Redis commands - Use redis skill for low-level operations
  • Non-Spring applications - Use Jedis or Lettuce directly
  • Primary database - Redis is for caching, not primary storage
  • Complex queries - Use SQL databases for complex queries

Anti-Patterns

Anti-PatternProblemSolution
No TTL on cached dataMemory exhaustionAlways set expiration
Large objects in cacheMemory pressureKeep values small
Cache stampedeThundering herdUse distributed locks
@Cacheable on void methodsNo effectOnly cache return values
Caching mutable objectsStale dataCache immutable or clone
No connection poolingConnection exhaustionConfigure Lettuce pool

Quick Troubleshooting

ProblemDiagnosticFix
Connection refusedCheck Redis runningStart Redis, check host/port
Cache not workingCheck @EnableCachingAdd annotation, verify AOP proxy
Serialization errorCheck object typeConfigure proper serializer
Memory issuesredis-cli INFO memorySet maxmemory, eviction policy

Production Checklist

  • Connection pool configured
  • TTL set on all keys
  • Serializers configured
  • Cluster/Sentinel for HA
  • Memory limits set
  • Eviction policy configured
  • Monitoring enabled
  • Error handling for failures

Reference Documentation

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.33%
按下载量换算92

Claude

28.26%
按下载量换算70

Cursor

17.4%
按下载量换算43

Gemini CLI

9.9%
按下载量换算24

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills