TtlIndex implements IndexDefinition
Read onlyYes
Time-to-live index definition.
The server periodically removes documents whose indexed attribute
value (interpreted as a numeric Unix timestamp in seconds, or as a
date string in ISO 8601) is older than $expireAfter seconds.
Only one TTL index per collection is allowed.
Example:
$sessions->createIndex
(
new TtlIndex
(
fields : [ 'createdAt' ] ,
expireAfter : 3600 , // one hour
)
) ;
Tags
Table of Contents
Interfaces
- IndexDefinition
- Common contract for every index definition consumable by {@see \oihana\arango\clients\collection\Collection::createIndex()}.
Properties
- $expireAfter : int
- $fields : array<string|int, mixed>
- $inBackground : bool|null
- $name : string|null
Methods
- __construct() : mixed
- toArray() : array<string, mixed>
- Returns the request body for `POST /_api/index` corresponding to this index definition.
Properties
$expireAfter
public
int
$expireAfter
$fields
public
array<string|int, mixed>
$fields
$inBackground
public
bool|null
$inBackground
= null
$name
public
string|null
$name
= null
Methods
__construct()
public
__construct(array<int, string> $fields, int $expireAfter[, string|null $name = null ][, bool|null $inBackground = null ]) : mixed
Parameters
- $fields : array<int, string>
-
Exactly one field path holding the reference date / timestamp.
- $expireAfter : int
-
Document lifetime, in seconds, past the indexed timestamp.
- $name : string|null = null
-
Optional human-readable index name.
- $inBackground : bool|null = null
-
Build the index in the background.
toArray()
Returns the request body for `POST /_api/index` corresponding to this index definition.
public
toArray() : array<string, mixed>