← Back to Documentation Home

STRUCT

Bucket

public struct Bucket: Codable, Equatable

Represents a bucket for storing experiment/variation assignments

Methods

init()

public init()

add(_:_:)

public mutating func add(_ key: String, _ value: String)

Add an item to the bucket - Parameters: - key: The key (experiment/variation ID) - value: The value (experiment/variation slug)

Parameters

Name Description
key The key (experiment/variation ID)
value The value (experiment/variation slug)

get(_:)

public func get(_ key: String) -> String?

Get an item from the bucket - Parameter key: The key to retrieve - Returns: The value or nil if not found

Parameters

Name Description
key The key to retrieve

getBucketedAt(_:)

public func getBucketedAt(_ key: String) -> Date?

Get the date when an item was bucketed - Parameter key: The key to check - Returns: The date or nil if not found

Parameters

Name Description
key The key to check

contains(_:)

public func contains(_ key: String) -> Bool

Check if the bucket contains a key - Parameter key: The key to check - Returns: True if the key exists

Parameters

Name Description
key The key to check

getSize()

public func getSize() -> Int

Get the size of the bucket - Returns: The number of items in the bucket

getBucket()

public func getBucket() -> [String: String]

Get all bucket entries - Returns: Dictionary of all entries

remove(_:)

public mutating func remove(_ key: String)

Remove an item from the bucket - Parameter key: The key to remove

Parameters

Name Description
key The key to remove

clear()

public mutating func clear()

Clear all items from the bucket