Behavior¶
- class aerospike_sdk.policy.behavior.Behavior[source]¶
Bases:
objectImmutable, scope-aware configuration for Aerospike operation policies.
A Behavior holds a set of scope-keyed
Settingspatches that are resolved at operation time based on the operation’s kind, shape, and namespace mode. More-specific scopes override less-specific ones, and a child Behavior inherits from its parent.Resolved settings are eagerly cached at construction time so that
get_settings()is a simple dict lookup.Example:
# Use a pre-defined behavior session = cluster.create_session(Behavior.DEFAULT) # Derive a custom behavior with scope-specific overrides fast = Behavior.DEFAULT.derive_with_changes( "fast_reads", reads=Settings(total_timeout=timedelta(milliseconds=200)), reads_batch=Settings(max_concurrent_nodes=8), ) session = cluster.create_session(fast)
- DEFAULT¶
Balanced defaults (30 s total timeout, 2 retries, send key).
- READ_FAST¶
Low-latency reads (200 ms total, 50 ms socket, 3 retries).
- STRICTLY_CONSISTENT¶
SC-namespace reads with linearizable consistency.
- FAST_RACK_AWARE¶
Low-latency rack-preferred reads.
- DEFAULT: ClassVar[Behavior] = Behavior(name='DEFAULT', total_timeout=0:00:30, socket_timeout=0:00:05, max_retries=2)¶
- READ_FAST: ClassVar[Behavior] = Behavior(name='READ_FAST', total_timeout=0:00:00.200000, socket_timeout=0:00:00.050000, max_retries=3)¶
- STRICTLY_CONSISTENT: ClassVar[Behavior] = Behavior(name='STRICTLY_CONSISTENT', total_timeout=0:00:30, socket_timeout=0:00:05, max_retries=2)¶
- FAST_RACK_AWARE: ClassVar[Behavior] = Behavior(name='FAST_RACK_AWARE', total_timeout=0:00:00.200000, socket_timeout=0:00:00.050000, max_retries=3)¶
- property children: List[Behavior]¶
Behaviors derived from this one via
derive_with_changes().
- get_settings(kind, shape, mode=Mode.AP)[source]¶
Return the fully-resolved Settings for the given operation context.
This is a cached O(1) dict lookup; the matrix is pre-computed at construction time.
- Return type:
- derive_with_changes(name, *, all=None, reads=None, reads_point=None, reads_batch=None, reads_query=None, reads_ap=None, reads_sc=None, writes=None, writes_retryable=None, writes_non_retryable=None, writes_point=None, writes_batch=None, writes_query=None, writes_ap=None, writes_sc=None, total_timeout=None, socket_timeout=None, max_retries=None, retry_delay=None, send_key=None, use_compression=None)[source]¶
Create a child Behavior with the specified overrides.
Accepts either scope-keyed
Settingsobjects or flat keyword arguments (which are applied to theALLscope). Both styles can be combined; flat kwargs are merged into theallSettings.Example:
fast_reads = default_behavior.derive_with_changes( "fast_reads", reads=Settings(total_timeout=timedelta(milliseconds=200)), )
- Return type:
Behavior Settings¶
Settings and scope types for the Behavior model.
- class aerospike_sdk.policy.behavior_settings.OpKind[source]¶
Bases:
EnumThe kind of database operation.
- READ = 'read'¶
- WRITE_RETRYABLE = 'write_retryable'¶
- WRITE_NON_RETRYABLE = 'write_non_retryable'¶
- class aerospike_sdk.policy.behavior_settings.OpShape[source]¶
Bases:
EnumThe shape (cardinality) of the operation.
- POINT = 'point'¶
- BATCH = 'batch'¶
- QUERY = 'query'¶
- class aerospike_sdk.policy.behavior_settings.Mode[source]¶
Bases:
EnumNamespace consistency mode.
- AP = 'ap'¶
- SC = 'sc'¶
- class aerospike_sdk.policy.behavior_settings.Scope[source]¶
Bases:
EnumNamed scopes for configuring operation settings within a Behavior.
Scope values correspond to keyword arguments accepted by
Behavior.derive_with_changes().- ALL = 'all'¶
- READS = 'reads'¶
- READS_POINT = 'reads_point'¶
- READS_BATCH = 'reads_batch'¶
- READS_QUERY = 'reads_query'¶
- READS_AP = 'reads_ap'¶
- READS_SC = 'reads_sc'¶
- WRITES = 'writes'¶
- WRITES_RETRYABLE = 'writes_retryable'¶
- WRITES_NON_RETRYABLE = 'writes_non_retryable'¶
- WRITES_POINT = 'writes_point'¶
- WRITES_BATCH = 'writes_batch'¶
- WRITES_QUERY = 'writes_query'¶
- WRITES_AP = 'writes_ap'¶
- WRITES_SC = 'writes_sc'¶
- class aerospike_sdk.policy.behavior_settings.Settings[source]¶
Bases:
objectImmutable set of operation settings.
All fields are Optional;
Nonemeans “not configured / inherit from a less-specific scope or the parent Behavior”.- classmethod merge(base, override)[source]¶
Merge two Settings; override’s non-None fields win.
- Return type:
- __init__(total_timeout=None, socket_timeout=None, max_retries=None, retry_delay=None, send_key=None, durable_delete=None, commit_level=None, replica=None, read_mode_ap=None, read_mode_sc=None, use_compression=None, max_concurrent_nodes=None, record_queue_size=None, allow_inline=None, allow_inline_ssd=None, read_touch_ttl_percent=None)¶