Oihana PHP Arango

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
see
https://docs.arangodb.com/stable/index-and-search/indexing/working-with-indexes/ttl-indexes/
author

Marc Alcaraz (ekameleon)

since
1.0.0

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

$fields

public array<string|int, mixed> $fields

$inBackground

public bool|null $inBackground = 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>
Tags
inheritDoc
Return values
array<string, mixed>
On this page

Search results