# Record metadata

Aerospike record metadata expressions allow you to access and evaluate record-level metadata in queries.

This guide covers expressions like `record_size`, `key_exists`, `ttl`, `last_update`, and `since_update`, which return details such as record size, existence, and update times. Code examples show how to use these expressions for efficient filtering and data retrieval.

## Ops

#### `device_size`

```python
device_size()
```

Description: Deprecated in Database 8.1. Use [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) instead. Returns the record’s storage size in bytes as an integer. Value is 0 when namespace is configured [`storage-engine memory`](https://aerospike.com/database/reference/config#namespace__storage-engine).

Returns: `integer_value`

Introduced: 5.2.0.4

Example: Find records that occupy more than 1 MiB of storage space.

-   [c](#tab-panel-591)
-   [java](#tab-panel-592)

```c
as_exp_build(predexp,

  as_exp_gt(as_exp_device_size(), as_exp_int(1024 * 1024)));
```

```java
Expression exp = Exp.build(

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

---

#### `digest_modulo`

```python
digest_modulo(mod)
```

Description: Returns a record digest modulo as an integer.

Arguments: | Name | Type |
| --- | --- |
| `mod` | `integer_value` |

Returns: `integer_value`

Introduced: 5.2.0.4

Example: Sample records where digest mod 3 equals 0

-   [c](#tab-panel-593)
-   [java](#tab-panel-594)

```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)));
```

---

#### `is_tombstone`

```python
is_tombstone()
```

Description: Returns `true` if the record is a tombstone, otherwise it returns `false`.  
**Note:** Only applies to XDR filters and when used in a write request with a read/write expressions.

Returns: `boolean_value`

Introduced: 5.2.0.4

Example: Create an XDR filter to only ship tombstones.

-   [c](#tab-panel-595)
-   [java](#tab-panel-596)

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

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

---

#### `key_exists`

```python
key_exists()
```

Description: “Returns `true` if the record has a stored key, otherwise it returns `false`.”

Returns: `boolean_value`

Introduced: 5.2.0.4

Example: Return all records that have a stored key.

-   [c](#tab-panel-597)
-   [java](#tab-panel-598)

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

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

---

#### `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_value`

Introduced: 5.2.0.4

Example: Return all records where the last-update-time is less than bin ‘updateBy’.

-   [c](#tab-panel-599)
-   [java](#tab-panel-600)

```c
as_exp_build(predexp,

  as_exp_cmp_lt(

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

```java
Expression exp = Exp.build(

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

---

#### `memory_size`

```python
memory_size()
```

Description: Deprecated in Database 8.1. Use [`record_size`](https://aerospike.com/docs/develop/expressions/metadata#record_size) instead. Returns the record’s size in bytes as an integer when the namespace is configured [`storage-engine memory`](https://aerospike.com/docs/database/reference/config#namespace__storage-engine), otherwise returns 0.

Prior to Database 7.0: Returns the record’s memory size in bytes as an integer when either the namespace is configured [`data-in-memory true`](https://aerospike.com/docs/database/reference/config#namespace__data-in-memory) or \[`storage-engine memory`\](/database/reference/config#namespace\_\_storage-engine”, otherwise returns 0.

Note: deprecated as of Database 7.0.0 since the `data-size` and `memory-size` are now the same size. Use [`record_size`](#record_size) instead.

Returns: `integer_value`

Introduced: 5.3.0

Example: Find records that occupy more than 1 MiB of memory.

-   [c](#tab-panel-601)
-   [java](#tab-panel-602)

```c
as_exp_build(predexp,

  as_exp_gt(as_exp_memory_size(), as_exp_int(1024 * 1024)));
```

```java
Expression exp = Exp.build(

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

---

#### `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_value`

Introduced: 7.0.0

Example: Find records that occupy more than 1 MiB of memory.

-   [c](#tab-panel-603)
-   [java](#tab-panel-604)

```c
as_exp_build(predexp,

  as_exp_gt(as_exp_record_size(), as_exp_int(1024 * 1024)));
```

```java
Expression exp = Exp.build(

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

---

#### `set_name`

```python
set_name()
```

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

Returns: `string_value`

Introduced: 5.2.0.4

Example: Return all records where the set\_name is either ‘groupA’ or ‘groupB’.

-   [c](#tab-panel-605)
-   [java](#tab-panel-606)

```c
as_exp_build(predexp, as_exp_or(

  as_exp_cmp_eq(as_exp_set_name(), as_exp_str("groupA")),

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

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

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

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

---

#### `since_update`

```python
since_update()
```

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

Returns: `integer_value`

Introduced: 5.2.0.4

Example: Return records that were updated within the last 2 hours.

-   [c](#tab-panel-607)
-   [java](#tab-panel-608)

```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)));
```

---

#### `ttl`

```python
ttl()
```

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

Returns: `integer_value`

Introduced: 5.2.0.4

Example: Return all records that will expire within 24 hours.

-   [c](#tab-panel-609)
-   [java](#tab-panel-610)

```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)));
```

---

#### `void_time`

```python
void_time()
```

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

Returns: `integer_value`

Introduced: 5.2.0.4

Example: Return all records where the void-time is set to ‘never expire’.

-   [c](#tab-panel-611)
-   [java](#tab-panel-612)

```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)));
```

---