Are you an LLM? You can read better optimized documentation at /guide/extensions/cosid-redis.md for this page in Markdown format
CosId-Redis Module
cosid-spring-redis module provides support for Redis. Implements:
MachineIdDistributor: As the machine ID distributor for Snowflake algorithm (SnowflakeId).IdSegmentDistributor: As the segment distributor for segment algorithm (SegmentId).
Installation
kotlin
val cosidVersion = "latestVersion"
implementation("org.springframework.boot:spring-boot-starter-data-redis")
implementation("me.ahoo.cosid:cosid-spring-redis:${cosidVersion}")xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>me.ahoo.cosid</groupId>
<artifactId>cosid-spring-redis</artifactId>
<version>${cosid.version}</version>
</dependency>
</dependencies>Configuration Example
yaml
spring:
data:
redis:
host: localhost # Redis distributor directly depends on spring-data-redis, which can omit additional configuration.
cosid:
namespace: ${spring.application.name}
machine:
enabled: true # Optional, needs to be set to true when using Snowflake algorithm
distributor:
type: redis
segment:
enabled: true # Optional, needs to be set to true when using segment algorithm
distributor:
type: redis