---
title: "Record metadata"
description: "Aerospike documentation for record metadata expressions including TTL, record size, set names, and last-update time."
---

# Record metadata

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

Record metadata expressions read Aerospike-managed fields: TTL and void time, digest sampling, set name, stored key flag, record size, last-update and time-since-update, and tombstone state (where applicable). Use them in secondary index filters, query predicates, record policies, and XDR shipping filters—anywhere the client accepts a boolean or typed expression over record metadata.

Wrap metadata values in [comparison](https://aerospike.com/docs/develop/expressions/comparison) or [logic](https://aerospike.com/docs/develop/expressions/logic) expressions when you need a boolean filter (true / false / unknown). For how metadata-only evaluation interacts with the rest of an expression, see the [expressions overview](https://aerospike.com/docs/develop/expressions/) execution model.

`memory_size` and `device_size` are deprecated with warnings in Database 8.1 and later. Use [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size), introduced in 7.0, instead. It returns a consistent value regardless of storage engine.

The Developer SDK’s [AEL](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference) text syntax exposes the same metadata as path functions on `$`, for example `$.ttl() < 3600`.

Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the `Exp` builder on the other seven. See the [AEL reference](https://aerospike.com/docs/develop/client/sdk/concepts/ael/reference) for AEL grammar.

## Ops

#### `device_size`

`deprecated`

```python
device_size()
```

Description: Returns the record’s storage size in bytes, or 0 when the namespace is configured [`storage-engine memory`](https://aerospike.com/docs/database/reference/config#namespace__storage-engine). Superseded by [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) in Database 8.1.

Returns: `integer`

Introduced: 5.2.0.4

Example: (Deprecated.) When still using device-size metadata on disk-backed namespaces, find records over 128 KiB. Prefer [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) on Database 7.0 and later.

-   [Java SDK](#tab-panel-2245)
-   [Python SDK](#tab-panel-2246)
-   [Rust](#tab-panel-2247)
-   [C#](#tab-panel-2248)
-   [Go](#tab-panel-2249)
-   [Node.js](#tab-panel-2250)
-   [C](#tab-panel-2251)
-   [Java](#tab-panel-2252)
-   [Python](#tab-panel-2253)

```java
String exp = "$.deviceSize() > 128 * 1024";
```

```python
exp = "$.deviceSize() > 128 * 1024"
```

```rust
use aerospike::expressions::{device_size, gt, int_val};

let exp = gt(device_size(), int_val(128 * 1024));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(Exp.DeviceSize(), Exp.Val(128 * 1024)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpGreater(as.ExpDeviceSize(), as.ExpIntVal(128*1024))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.gt(exp.deviceSize(), exp.int(128 * 1024))
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(as_exp_device_size(), as_exp_int(128 * 1024)));
```

```java
Expression exp = Exp.build(

  Exp.gt(Exp.deviceSize(), Exp.val(128 * 1024)));
```

```python
from aerospike_helpers.expressions import DeviceSize, GT

exp = GT(DeviceSize(), 128 * 1024).compile()
```

---

#### `digest_modulo`

```python
digest_modulo(mod)
```

Description: Returns a record digest modulo as an integer.

Arguments: | Name | Type | Description |
| --- | --- | --- |
| `mod` | `integer literal` | 
Divisor applied to the record digest. The expression returns the remainder, so a `mod` of 3 yields 0, 1 or 2 — enough to sample a fixed fraction of records.

 |

Returns: `integer`

Introduced: 5.2.0.4

Example: Sample roughly one third of records (digest modulo 3 equals 0).

-   [Java SDK](#tab-panel-2254)
-   [Python SDK](#tab-panel-2255)
-   [Rust](#tab-panel-2256)
-   [C#](#tab-panel-2257)
-   [Go](#tab-panel-2258)
-   [Node.js](#tab-panel-2259)
-   [C](#tab-panel-2260)
-   [Java](#tab-panel-2261)
-   [Python](#tab-panel-2262)

```java
String exp = "$.digestModulo(3) == 0";
```

```python
exp = "$.digestModulo(3) == 0"
```

```rust
use aerospike::expressions::{digest_modulo, eq, int_val};

let exp = eq(digest_modulo(3), int_val(0));
```

```csharp
Expression exp = Exp.Build(

  Exp.EQ(Exp.DigestModulo(3), Exp.Val(0)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpEq(as.ExpDigestModulo(3), as.ExpIntVal(0))
```

```javascript
// The Node.js client's exp.digestModulo drops its divisor, so the server rejects

// the expression and this example has no Node.js form.
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(as_exp_digest_modulo(3), as_exp_int(0)));
```

```java
Expression exp = Exp.build(

  Exp.eq(Exp.digestModulo(3), Exp.val(0)));
```

```python
from aerospike_helpers.expressions import DigestMod, Eq

exp = Eq(DigestMod(3), 0).compile()
```

---

#### `is_tombstone`

```python
is_tombstone()
```

Description: Returns `true` if the record is a tombstone, otherwise `false`. **Note:** Applies to XDR filters and to write requests using read/write expressions.

Returns: `boolean`

Introduced: 5.2.0.4

Example: XDR shipping filter — select tombstone records only.

-   [Java SDK](#tab-panel-2263)
-   [Python SDK](#tab-panel-2264)
-   [Rust](#tab-panel-2265)
-   [C#](#tab-panel-2266)
-   [Go](#tab-panel-2267)
-   [Node.js](#tab-panel-2268)
-   [C](#tab-panel-2269)
-   [Java](#tab-panel-2270)
-   [Python](#tab-panel-2271)

```java
String exp = "$.isTombstone()";
```

```python
exp = "$.isTombstone()"
```

```rust
use aerospike::expressions::is_tombstone;

let exp = is_tombstone();
```

```csharp
Expression exp = Exp.Build(Exp.IsTombstone());
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpIsTombstone()
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.isTombstone()
```

```c
as_exp_build(predexp, as_exp_is_tombstone());
```

```java
Expression exp = Exp.build(Exp.isTombstone());
```

```python
from aerospike_helpers.expressions import IsTombstone

exp = IsTombstone().compile()
```

---

#### `key_exists`

```python
key_exists()
```

Description: Returns `true` if the record has a stored key (written with the write policy’s send-key option), otherwise `false`. Once stored, the key persists with the record until the record is deleted.

Returns: `boolean`

Introduced: 5.2.0.4

Example: Return records that have a stored primary key in the record metadata.

-   [Java SDK](#tab-panel-2272)
-   [Python SDK](#tab-panel-2273)
-   [Rust](#tab-panel-2274)
-   [C#](#tab-panel-2275)
-   [Go](#tab-panel-2276)
-   [Node.js](#tab-panel-2277)
-   [C](#tab-panel-2278)
-   [Java](#tab-panel-2279)
-   [Python](#tab-panel-2280)

```java
String exp = "$.keyExists()";
```

```python
exp = "$.keyExists()"
```

```rust
use aerospike::expressions::key_exists;

let exp = key_exists();
```

```csharp
Expression exp = Exp.Build(Exp.KeyExists());
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpKeyExists()
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.keyExist()
```

```c
as_exp_build(predexp, as_exp_key_exist());
```

```java
Expression exp = Exp.build(Exp.keyExists());
```

```python
from aerospike_helpers.expressions import KeyExists

exp = KeyExists().compile()
```

---

#### `last_update`

```python
last_update()
```

Description: Returns the record’s last-update-time (LUT) in nanoseconds (millisecond resolution) from Unix Epoch (1/1/1970) as an integer.

Returns: `integer`

Introduced: 5.2.0.4

Example: Return records whose server last-update time (LUT, nanoseconds since epoch) is less than integer bin `updated_at` (for example, an application timestamp in the same units).

-   [Java SDK](#tab-panel-2281)
-   [Python SDK](#tab-panel-2282)
-   [Rust](#tab-panel-2283)
-   [C#](#tab-panel-2284)
-   [Go](#tab-panel-2285)
-   [Node.js](#tab-panel-2286)
-   [C](#tab-panel-2287)
-   [Java](#tab-panel-2288)
-   [Python](#tab-panel-2289)

```java
String exp = "$.lastUpdateTime() < $.updated_at";
```

```python
exp = "$.lastUpdateTime() < $.updated_at"
```

```rust
use aerospike::expressions::{int_bin, last_update, lt};

let exp = lt(last_update(), int_bin("updated_at".into()));
```

```csharp
Expression exp = Exp.Build(

  Exp.LT(Exp.LastUpdate(), Exp.IntBin("updated_at")));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpLess(as.ExpLastUpdate(), as.ExpIntBin("updated_at"))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.lt(exp.lastUpdate(), exp.binInt('updated_at'))
```

```c
as_exp_build(predexp,

  as_exp_cmp_lt(

    as_exp_last_update(), as_exp_bin_int("updated_at")));
```

```java
Expression exp = Exp.build(

  Exp.lt(Exp.lastUpdate(), Exp.intBin("updated_at")));
```

```python
from aerospike_helpers.expressions import IntBin, LastUpdateTime, LT

exp = LT(LastUpdateTime(), IntBin("updated_at")).compile()
```

---

#### `memory_size`

`deprecated`

```python
memory_size()
```

Description: Returns the record’s size in bytes when the namespace is configured [`storage-engine memory`](https://aerospike.com/docs/database/reference/config#namespace__storage-engine), otherwise 0. Before Database 7.0 it also returned a size when the namespace was configured [`data-in-memory true`](https://aerospike.com/docs/database/reference/config#namespace__data-in-memory); since 7.0 the data size and memory size are the same. Superseded by [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) in Database 8.1.

Returns: `integer`

Introduced: 5.3.0

Example: (Deprecated.) When still using legacy memory-size metadata, find records over 128 KiB. Prefer [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) on Database 7.0 and later.

-   [Java SDK](#tab-panel-2290)
-   [Python SDK](#tab-panel-2291)
-   [Rust](#tab-panel-2292)
-   [C#](#tab-panel-2293)
-   [Go](#tab-panel-2294)
-   [Node.js](#tab-panel-2295)
-   [C](#tab-panel-2296)
-   [Java](#tab-panel-2297)
-   [Python](#tab-panel-2298)

```java
String exp = "$.memorySize() > 128 * 1024";
```

```python
exp = "$.memorySize() > 128 * 1024"
```

```rust
use aerospike::expressions::{gt, int_val, memory_size};

let exp = gt(memory_size(), int_val(128 * 1024));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(Exp.MemorySize(), Exp.Val(128 * 1024)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpGreater(as.ExpMemorySize(), as.ExpIntVal(128*1024))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.gt(exp.memorySize(), exp.int(128 * 1024))
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(as_exp_memory_size(), as_exp_int(128 * 1024)));
```

```java
Expression exp = Exp.build(

  Exp.gt(Exp.memorySize(), Exp.val(128 * 1024)));
```

```python
from aerospike_helpers.expressions import GT, MemorySize

exp = GT(MemorySize(), 128 * 1024).compile()
```

---

#### `record_size`

```python
record_size()
```

Description: Returns the record’s size in bytes as an integer. This is the physical size of the record in the namespace storage device. If compression is turned on, the record size reflects the compressed size of the record, not the logical uncompressed size.

Returns: `integer`

Introduced: 7.0.0

Example: Find records larger than 128 KiB on the storage device (compressed size when compression is enabled).

-   [Java SDK](#tab-panel-2299)
-   [Python SDK](#tab-panel-2300)
-   [Rust](#tab-panel-2301)
-   [C#](#tab-panel-2302)
-   [Go](#tab-panel-2303)
-   [Node.js](#tab-panel-2304)
-   [C](#tab-panel-2305)
-   [Java](#tab-panel-2306)
-   [Python](#tab-panel-2307)

```java
String exp = "$.recordSize() > 128 * 1024";
```

```python
exp = "$.recordSize() > 128 * 1024"
```

```rust
use aerospike::expressions::{gt, int_val, record_size};

let exp = gt(record_size(), int_val(128 * 1024));
```

```csharp
Expression exp = Exp.Build(

  Exp.GT(Exp.RecordSize(), Exp.Val(128 * 1024)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpGreater(as.ExpRecordSize(), as.ExpIntVal(128*1024))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.gt(exp.recordSize(), exp.int(128 * 1024))
```

```c
as_exp_build(predexp,

  as_exp_cmp_gt(as_exp_record_size(), as_exp_int(128 * 1024)));
```

```java
Expression exp = Exp.build(

  Exp.gt(Exp.recordSize(), Exp.val(128 * 1024)));
```

```python
from aerospike_helpers.expressions import GT, RecordSize

exp = GT(RecordSize(), 128 * 1024).compile()
```

---

#### `set_name`

```python
set_name()
```

Description: Returns the record’s set\_name as a string.

Returns: `string`

Introduced: 5.2.0.4

Example: Return records in Aerospike sets `books` or `bundles` (aligned with catalog-style examples elsewhere).

-   [Java SDK](#tab-panel-2308)
-   [Python SDK](#tab-panel-2309)
-   [Rust](#tab-panel-2310)
-   [C#](#tab-panel-2311)
-   [Go](#tab-panel-2312)
-   [Node.js](#tab-panel-2313)
-   [C](#tab-panel-2314)
-   [Java](#tab-panel-2315)
-   [Python](#tab-panel-2316)

```java
String exp = "$.setName() == 'books' or $.setName() == 'bundles'";
```

```python
exp = "$.setName() == 'books' or $.setName() == 'bundles'"
```

```rust
use aerospike::expressions::{eq, or, set_name, string_val};

let exp = or(vec![

    eq(set_name(), string_val("books".into())),

    eq(set_name(), string_val("bundles".into())),

]);
```

```csharp
Expression exp = Exp.Build(Exp.Or(

  Exp.EQ(Exp.SetName(), Exp.Val("books")),

  Exp.EQ(Exp.SetName(), Exp.Val("bundles"))));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpOr(

  as.ExpEq(as.ExpSetName(), as.ExpStringVal("books")),

  as.ExpEq(as.ExpSetName(), as.ExpStringVal("bundles")),

)
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.or(

  exp.eq(exp.setName(), exp.str('books')),

  exp.eq(exp.setName(), exp.str('bundles')),

)
```

```c
as_exp_build(predexp, as_exp_or(

  as_exp_cmp_eq(as_exp_set_name(), as_exp_str("books")),

  as_exp_cmp_eq(as_exp_set_name(), as_exp_str("bundles"))));
```

```java
Expression exp = Exp.build(Exp.or(

  Exp.eq(Exp.setName(), Exp.val("books")),

  Exp.eq(Exp.setName(), Exp.val("bundles"))));
```

```python
from aerospike_helpers.expressions import Eq, Or, SetName

exp = Or(Eq(SetName(), "books"), Eq(SetName(), "bundles")).compile()
```

---

#### `since_update`

```python
since_update()
```

Description: Returns the time (in milliseconds) since the record was last updated.

Returns: `integer`

Introduced: 5.2.0.4

Example: Return records updated within the last 2 hours (milliseconds since last update).

-   [Java SDK](#tab-panel-2317)
-   [Python SDK](#tab-panel-2318)
-   [Rust](#tab-panel-2319)
-   [C#](#tab-panel-2320)
-   [Go](#tab-panel-2321)
-   [Node.js](#tab-panel-2322)
-   [C](#tab-panel-2323)
-   [Java](#tab-panel-2324)
-   [Python](#tab-panel-2325)

```java
String exp = "$.timeSinceLastUpdate() < 2 * 60 * 60 * 1000";
```

```python
exp = "$.timeSinceLastUpdate() < 2 * 60 * 60 * 1000"
```

```rust
use aerospike::expressions::{int_val, lt, since_update};

let exp = lt(since_update(), int_val(2 * 60 * 60 * 1000));
```

```csharp
Expression exp = Exp.Build(

  Exp.LT(Exp.SinceUpdate(), Exp.Val(2 * 60 * 60 * 1000)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpLess(as.ExpSinceUpdate(), as.ExpIntVal(2*60*60*1000))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.lt(exp.sinceUpdate(), exp.int(2 * 60 * 60 * 1000))
```

```c
as_exp_build(predexp,

  as_exp_cmp_lt(

    as_exp_since_update(), as_exp_int(2 * 60 * 60 * 1000)));
```

```java
Expression exp = Exp.build(

  Exp.lt(Exp.sinceUpdate(), Exp.val(2 * 60 * 60 * 1000)));
```

```python
from aerospike_helpers.expressions import LT, SinceUpdateTime

exp = LT(SinceUpdateTime(), 2 * 60 * 60 * 1000).compile()
```

---

#### `ttl`

```python
ttl()
```

Description: Returns the record’s TTL (Time To Live) as an integer.

Returns: `integer`

Introduced: 5.2.0.4

Example: Return records whose TTL is at most 24 hours (seconds remaining until expiration).

-   [Java SDK](#tab-panel-2326)
-   [Python SDK](#tab-panel-2327)
-   [Rust](#tab-panel-2328)
-   [C#](#tab-panel-2329)
-   [Go](#tab-panel-2330)
-   [Node.js](#tab-panel-2331)
-   [C](#tab-panel-2332)
-   [Java](#tab-panel-2333)
-   [Python](#tab-panel-2334)

```java
String exp = "$.ttl() <= 24 * 60 * 60";
```

```python
exp = "$.ttl() <= 24 * 60 * 60"
```

```rust
use aerospike::expressions::{int_val, le, ttl};

let exp = le(ttl(), int_val(24 * 60 * 60));
```

```csharp
Expression exp = Exp.Build(

  Exp.LE(Exp.TTL(), Exp.Val(24 * 60 * 60)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpLessEq(as.ExpTTL(), as.ExpIntVal(24*60*60))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.le(exp.ttl(), exp.int(24 * 60 * 60))
```

```c
as_exp_build(predexp,

  as_exp_cmp_le(as_exp_ttl(), as_exp_int(24 * 60 * 60)));
```

```java
Expression exp = Exp.build(

  Exp.le(Exp.ttl(), Exp.val(24 * 60 * 60)));
```

```python
from aerospike_helpers.expressions import LE, TTL

exp = LE(TTL(), 24 * 60 * 60).compile()
```

---

#### `void_time`

```python
void_time()
```

Description: Returns the record’s expiration time in nanoseconds (resolution in seconds) as an integer.

Returns: `integer`

Introduced: 5.2.0.4

Example: Return records that never expire (void time `-1`).

-   [Java SDK](#tab-panel-2335)
-   [Python SDK](#tab-panel-2336)
-   [Rust](#tab-panel-2337)
-   [C#](#tab-panel-2338)
-   [Go](#tab-panel-2339)
-   [Node.js](#tab-panel-2340)
-   [C](#tab-panel-2341)
-   [Java](#tab-panel-2342)
-   [Python](#tab-panel-2343)

```java
String exp = "$.voidTime() == -1";
```

```python
exp = "$.voidTime() == -1"
```

```rust
use aerospike::expressions::{eq, int_val, void_time};

let exp = eq(void_time(), int_val(-1));
```

```csharp
Expression exp = Exp.Build(Exp.EQ(Exp.VoidTime(), Exp.Val(-1)));
```

```go
// Requires: import as "github.com/aerospike/aerospike-client-go/v8"

exp := as.ExpEq(as.ExpVoidTime(), as.ExpIntVal(-1))
```

```javascript
const exp = Aerospike.exp

const filterExp = exp.eq(exp.voidTime(), exp.int(-1))
```

```c
as_exp_build(predexp,

  as_exp_cmp_eq(as_exp_void_time(), as_exp_int(-1)));
```

```java
Expression exp = Exp.build(Exp.eq(Exp.voidTime(), Exp.val(-1)));
```

```python
from aerospike_helpers.expressions import Eq, VoidTime

exp = Eq(VoidTime(), -1).compile()
```

---