Skip to content

ConfigurationAwareAssignmentStore ​

Rasuvaeff\Yii3AbTesting\ConfigurationAwareAssignmentStore

Interface · rasuvaeff/yii3-ab-testing · Source · extends AssignmentStore

Optional extension for stores that invalidate a sticky variant when the experiment configuration changes.

A plain AssignmentStore pins a subject to a variant forever. That is right while the experiment is stable and wrong once it is reweighted: the subject keeps a variant drawn from boundaries that no longer exist. A configuration-aware store reuses the stored variant only for the configuration it was drawn from.

Lives in the core rather than in one adapter because more than one storage implements it — a signed cookie in the web package, a table in the database package — and they must not have to depend on each other to share the contract.

Methods ​

getForConfiguration() ​

php
getForConfiguration(
    string $experiment,
    string $subjectId,
    ?string $configurationId,
): ?string
  • $configurationId — Identity of the experiment definition the caller is resolving against; null when it is unknown.

putForConfiguration() ​

php
putForConfiguration(
    string $experiment,
    string $subjectId,
    string $variant,
    ?string $configurationId,
): void