@valkey/valkey-glide
    Preparing search index...

    Type Alias GlideClusterClientConfiguration

    GlideClusterClientConfiguration: BaseClientConfiguration & {
        advancedConfiguration?: AdvancedGlideClusterClientConfiguration;
        periodicChecks?: PeriodicChecks;
        pubsubSubscriptions?: GlideClusterClientConfiguration.PubSubSubscriptions;
    }

    Configuration options for creating a GlideClusterClient.

    Extends BaseClientConfiguration with properties specific to GlideClusterClient, such as periodic topology checks and Pub/Sub subscription settings.

    Type Declaration

    • OptionaladvancedConfiguration?: AdvancedGlideClusterClientConfiguration

      Advanced configuration settings for the client.

    • OptionalperiodicChecks?: PeriodicChecks

      Configure the periodic topology checks. These checks evaluate changes in the cluster's topology, triggering a slot refresh when detected. Periodic checks ensure a quick and efficient process by querying a limited number of nodes. If not set, enabledDefaultConfigs will be used.

    • OptionalpubsubSubscriptions?: GlideClusterClientConfiguration.PubSubSubscriptions

      PubSub subscriptions to be used for the client. Will be applied via SUBSCRIBE/PSUBSCRIBE/SSUBSCRIBE commands during connection establishment.

    This configuration allows you to tailor the client's behavior when connecting to a Valkey GLIDE Cluster.

    • Periodic Topology Checks: Use periodicChecks to configure how the client performs periodic checks to detect changes in the cluster's topology.
      • "enabledDefaultConfigs": Enables periodic checks with default configurations.
      • "disabled": Disables periodic topology checks.
      • { duration_in_sec: number }: Manually configure the interval for periodic checks.
    • Pub/Sub Subscriptions: Predefine Pub/Sub channels and patterns to subscribe to upon connection establishment.
      • Supports exact channels, patterns, and sharded channels (available since Valkey version 7.0).
    const config: GlideClusterClientConfiguration = {
    addresses: [
    { host: 'cluster-node-1.example.com', port: 6379 },
    { host: 'cluster-node-2.example.com', port: 6379 },
    ],
    databaseId: 5, // Connect to database 5 (requires Valkey 9.0+ with multi-database cluster mode)
    periodicChecks: {
    duration_in_sec: 30, // Perform periodic checks every 30 seconds
    },
    pubsubSubscriptions: {
    channelsAndPatterns: {
    [GlideClusterClientConfiguration.PubSubChannelModes.Pattern]: new Set(['cluster.*']),
    },
    callback: (msg) => {
    console.log(`Received message on ${msg.channel}:`, msg.payload);
    },
    },
    };