Class: Momento::Cache::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/momento/config/configuration.rb

Overview

Configuration options for Momento CacheClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport_strategy) ⇒ Configuration

Returns a new instance of Configuration.



37
38
39
# File 'lib/momento/config/configuration.rb', line 37

def initialize(transport_strategy)
  @transport_strategy = transport_strategy
end

Instance Attribute Details

#transport_strategyObject (readonly)

Returns the value of attribute transport_strategy.



5
6
7
# File 'lib/momento/config/configuration.rb', line 5

def transport_strategy
  @transport_strategy
end

Instance Method Details

#with_num_connections(num_connections) ⇒ Object

Convenience function to set the number of TCP connections for the client. Each connection can multiplex up to 100 concurrent requests. The default is 1, and this should not be overridden unless you are making a high volume of requests. Can help distribute traffic more evenly for high-throughput use cases.



22
23
24
25
26
27
28
29
30
# File 'lib/momento/config/configuration.rb', line 22

def with_num_connections(num_connections)
  transport_strategy = @transport_strategy
  grpc_config = transport_strategy.grpc_configuration
  Configuration.new(
    transport_strategy.with_grpc_configuration(
      grpc_config.with_num_grpc_channels(num_connections)
    )
  )
end

#with_timeout(timeout_millis) ⇒ Object

Convenience function to set the client timeout in milliseconds. If the server has not responded within the specified time, the client will terminate the request with a DeadlineExceeded error.



9
10
11
12
13
14
15
16
17
# File 'lib/momento/config/configuration.rb', line 9

def with_timeout(timeout_millis)
  transport_strategy = @transport_strategy
  grpc_config = transport_strategy.grpc_configuration
  Configuration.new(
    transport_strategy.with_grpc_configuration(
      grpc_config.with_deadline(timeout_millis)
    )
  )
end

#with_transport_strategy(transport_strategy) ⇒ Object

Copy constructor; creates a new Configuration with the specified transport strategy



33
34
35
# File 'lib/momento/config/configuration.rb', line 33

def with_transport_strategy(transport_strategy)
  Configuration.new(transport_strategy)
end