Class KeyValueConfig

  • All Implemented Interfaces:

    
    public final class KeyValueConfig
    
                        

    DSL 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
    }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String getDescription() Optional description of the bucket
      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
      final Integer getMaxValueSize() Maximum size in bytes for a single value Default: -1 (server default, typically 1MB)
      final Long getMaxBucketSize() Maximum number of bytes for the entire bucket Default: -1 (unlimited)
      final Duration getTtl() Time-to-live for entries in the bucket Default: Duration.
      final StorageType getStorageType() 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 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)
      final Placement getPlacement() Placement constraints for the bucket Only relevant in cluster mode
      final Boolean getCompression() Compression option for the bucket Default: false (no compression)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • 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)