Class KeyValueConfig
-
- All Implemented Interfaces:
public final class KeyValueConfigDSL builder for Key-Value store configuration
Provides a Kotlin-friendly way to configure Key-Value buckets with sensible defaults and compile-time validation.
Example:
val kvStore = js.keyValue("my-bucket") { description = "User preferences storage" maxHistoryPerKey = 10 ttl = 7.days storageType = StorageType.MEMORY replicas = 3 }
-
-
Field Summary
Fields Modifier and Type Field Description private final Stringdescriptionprivate final LongmaxHistoryPerKeyprivate final IntegermaxValueSizeprivate final LongmaxBucketSizeprivate final Durationttlprivate final StorageTypestorageTypeprivate final Integerreplicasprivate final Placementplacementprivate final Booleancompression
-
Method Summary
Modifier and Type Method Description final StringgetDescription()Optional description of the bucket final LonggetMaxHistoryPerKey()Maximum number of history entries per key (includes current value) Default: 1 (only keep current value) Set to higher value to track history of changes final IntegergetMaxValueSize()Maximum size in bytes for a single value Default: -1 (server default, typically 1MB) final LonggetMaxBucketSize()Maximum number of bytes for the entire bucket Default: -1 (unlimited) final DurationgetTtl()Time-to-live for entries in the bucket Default: Duration. final StorageTypegetStorageType()Storage type for the bucket Default: FILE for persistenceOptions: io.nats.client.api.StorageType.File: Persistent storage
io.nats.client.api.StorageType.Memory: In-memory only (faster but not durable)
final IntegergetReplicas()Number of replicas for the bucket (cluster mode) Default: 1 (single replica)For high availability, set to 3 or more (odd numbers recommended) final PlacementgetPlacement()Placement constraints for the bucket Only relevant in cluster mode final BooleangetCompression()Compression option for the bucket Default: false (no compression) -
-
Method Detail
-
getDescription
final String getDescription()
Optional description of the bucket
-
getMaxHistoryPerKey
final Long getMaxHistoryPerKey()
Maximum number of history entries per key (includes current value) Default: 1 (only keep current value) Set to higher value to track history of changes
-
getMaxValueSize
final Integer getMaxValueSize()
Maximum size in bytes for a single value Default: -1 (server default, typically 1MB)
-
getMaxBucketSize
final Long getMaxBucketSize()
Maximum number of bytes for the entire bucket Default: -1 (unlimited)
-
getTtl
final Duration getTtl()
Time-to-live for entries in the bucket Default: Duration.ZERO (no expiration)
Example: ttl = 24.hours
-
getStorageType
final StorageType getStorageType()
Storage type for the bucket Default: FILE for persistence
Options:
io.nats.client.api.StorageType.File: Persistent storage
io.nats.client.api.StorageType.Memory: In-memory only (faster but not durable)
-
getReplicas
final Integer getReplicas()
Number of replicas for the bucket (cluster mode) Default: 1 (single replica)
For high availability, set to 3 or more (odd numbers recommended)
-
getPlacement
final Placement getPlacement()
Placement constraints for the bucket Only relevant in cluster mode
-
getCompression
final Boolean getCompression()
Compression option for the bucket Default: false (no compression)
-
-
-