Skip to content

Commit 82abf48

Browse files
committed
refactor: use ULID instead of UUID4
1 parent f0444dd commit 82abf48

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

redisvl/index/storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import asyncio
2-
import uuid
32
from typing import Any, Callable, Dict, Iterable, List, Optional
43

54
from pydantic.v1 import BaseModel
65
from redis import Redis
76
from redis.asyncio import Redis as AsyncRedis
87
from redis.commands.search.indexDefinition import IndexType
8+
from ulid import ULID
99

1010
from redisvl.redis.utils import convert_bytes
1111

@@ -64,7 +64,7 @@ def _create_key(self, obj: Dict[str, Any], id_field: Optional[str] = None) -> st
6464
ValueError: If the id_field is not found in the object.
6565
"""
6666
if id_field is None:
67-
key_value = uuid.uuid4().hex
67+
key_value = str(ULID())
6868
else:
6969
try:
7070
key_value = obj[id_field] # type: ignore

redisvl/utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
from functools import wraps
44
from time import time
55
from typing import Any, Callable, Dict, Optional
6-
from uuid import uuid4
76
from warnings import warn
87

98
from pydantic.v1 import BaseModel
9+
from ulid import ULID
1010

1111

1212
def create_uuid() -> str:
1313
"""Generate a unique indentifier to group related Redis documents."""
14-
return str(uuid4())
14+
return str(ULID())
1515

1616

1717
def current_timestamp() -> float:

tests/unit/test_session_schema.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from uuid import uuid4
2-
31
import pytest
42
from pydantic.v1 import ValidationError
53

0 commit comments

Comments
 (0)