Table of Contents

Interface ICachedStorageBackend

Namespace
OptunaSharp.Storages
Assembly
OptunaSharp.dll

The backend contract CachedStorage wraps — the internal RDBStorage surface it drives in Python (_create_new_trial, _set_trial_param, _get_best_trial_id, _get_trials). The Tier X OptunaSharp.Storage.Sqlite/EFCore RDB storages implement this (PORTING_PLAN 4.1/4.2); the wrapper itself is Tier N because the read-through cache logic is reused there unchanged.

public interface ICachedStorageBackend : IBaseHeartbeat
Inherited Members

Methods

CreateNewTrialFull(int, FrozenTrial?)

Python RDBStorage._create_new_trial: create and return the full frozen trial.

FrozenTrial CreateNewTrialFull(int studyId, FrozenTrial? templateTrial = null)

Parameters

studyId int

Storage identifier of the study; distinct from its name.

templateTrial FrozenTrial

Optional record to copy; null creates a new running trial with empty observations.

Returns

FrozenTrial

The created trial including assigned storage identifier and per-study number.

Exceptions

KeyError

The study does not exist.

GetBestTrialId(int, StudyDirection)

Python RDBStorage._get_best_trial_id.

int GetBestTrialId(int studyId, StudyDirection direction)

Parameters

studyId int

Storage identifier of the study; distinct from its name.

direction StudyDirection

Direction used to order completed objective values.

Returns

int

Identifier of the best completed trial according to the supplied direction.

Exceptions

ValueError

The study has no completed trials.

GetTrialsPartial(int, IReadOnlyCollection<TrialState>?, IReadOnlyCollection<int>, int)

Python RDBStorage._get_trials(study_id, states, included_trial_ids, trial_id_greater_than): trials whose ID is in includedTrialIds or greater than trialIdGreaterThan.

List<FrozenTrial> GetTrialsPartial(int studyId, IReadOnlyCollection<TrialState>? states, IReadOnlyCollection<int> includedTrialIds, int trialIdGreaterThan)

Parameters

studyId int

Storage identifier of the study; distinct from its name.

states IReadOnlyCollection<TrialState>

States to include; null includes every state.

includedTrialIds IReadOnlyCollection<int>

Identifiers to fetch even when at or below the high-water mark.

trialIdGreaterThan int

Exclusive identifier threshold for fetching trials created since the previous refresh.

Returns

List<FrozenTrial>

Trials satisfying the state filter and either identifier selection condition.

SetTrialParamWithCachedDistribution(int, string, double, BaseDistribution, BaseDistribution?)

Python RDBStorage._set_trial_param with the cached distribution shortcut.

void SetTrialParamWithCachedDistribution(int trialId, string paramName, double paramValueInternal, BaseDistribution distribution, BaseDistribution? cachedDistribution)

Parameters

trialId int

Storage identifier of the trial; distinct from its per-study trial number.

paramName string

Parameter name used as the storage and distribution lookup key.

paramValueInternal double

Parameter value in the distribution's internal numeric representation.

distribution BaseDistribution

Distribution defining the parameter representation and allowed values.

cachedDistribution BaseDistribution

Previously cached distribution, or null when the backend must load it.

Exceptions

KeyError

The trial does not exist.

UpdateFinishedTrialError

The trial has finished.

ValueError

The proposed and stored distributions are incompatible.