Redis¶
The redis adapter provides a complete Redis integration including the concrete adapter, its abstract port interface,
and a mock implementation for testing.
Ports¶
Abstract port interface defining the Redis adapter contract.
archipy.adapters.redis.ports.RedisAbsExpiryType
module-attribute
¶
archipy.adapters.redis.ports.RedisIntegerResponseType
module-attribute
¶
archipy.adapters.redis.ports.RedisListResponseType
module-attribute
¶
archipy.adapters.redis.ports.RedisSetResponseType
module-attribute
¶
archipy.adapters.redis.ports.RedisSetType
module-attribute
¶
archipy.adapters.redis.ports.RedisScoreCastType
module-attribute
¶
archipy.adapters.redis.ports.RedisPort ¶
Interface for Redis operations providing a standardized access pattern.
This interface defines the contract for Redis adapters, ensuring consistent implementation of Redis operations across different adapters. It covers all essential Redis functionality including key-value operations, collections (lists, sets, sorted sets, hashes), and pub/sub capabilities.
Implementing classes should provide concrete implementations for all methods, typically by wrapping a Redis client library.
Source code in archipy/adapters/redis/ports.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 | |
archipy.adapters.redis.ports.RedisPort.ping
abstractmethod
¶
Tests the connection to the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The response from the server, typically "PONG". |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.pttl
abstractmethod
¶
Gets the remaining time to live of a key in milliseconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The time to live in milliseconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.incrby
abstractmethod
¶
Increments the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key to increment. |
required |
amount
|
int
|
The amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after incrementing. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.set
abstractmethod
¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Sets a key to a value with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key to set. |
required |
value
|
RedisSetType
|
The value to set for the key. |
required |
ex
|
RedisExpiryType
|
Expiration time in seconds or timedelta. |
None
|
px
|
RedisExpiryType
|
Expiration time in milliseconds or timedelta. |
None
|
nx
|
bool
|
If True, set only if the key does not exist. Defaults to False. |
False
|
xx
|
bool
|
If True, set only if the key already exists. Defaults to False. |
False
|
keepttl
|
bool
|
If True, retain the existing TTL. Defaults to False. |
False
|
get
|
bool
|
If True, return the old value before setting. Defaults to False. |
False
|
exat
|
RedisAbsExpiryType
|
Absolute expiration time as Unix timestamp or datetime. |
None
|
pxat
|
RedisAbsExpiryType
|
Absolute expiration time in milliseconds or datetime. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The result of the operation, often "OK" or the old value if get=True. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.get
abstractmethod
¶
Retrieves the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value associated with the key, or None if the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.mget
abstractmethod
¶
Gets the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
A single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of values corresponding to the keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.mset
abstractmethod
¶
Sets multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
A mapping of keys to values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Typically "OK" on success. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.keys
abstractmethod
¶
Returns all keys matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
The pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of matching keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.getset
abstractmethod
¶
Sets a key to a value and returns its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key to set. |
required |
value
|
bytes | str | float
|
The new value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The old value of the key, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.getdel
abstractmethod
¶
Gets the value of a key and deletes it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to get and delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key before deletion, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.exists
abstractmethod
¶
Checks if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to check. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of keys that exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.delete
abstractmethod
¶
Deletes one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of keys deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.append
abstractmethod
¶
Appends a value to a key's string value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key to append to. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The length of the string after appending. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.ttl
abstractmethod
¶
Gets the remaining time to live of a key in seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The time to live in seconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.type
abstractmethod
¶
Determines the type of value stored at a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The type of the key's value (e.g., "string", "list", etc.). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.llen
abstractmethod
¶
Gets the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of items in the list. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.lpop
abstractmethod
¶
Removes and returns the first element(s) of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.lpush
abstractmethod
¶
Pushes one or more values to the start of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.lrange
abstractmethod
¶
Gets a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
start
|
int
|
The starting index (inclusive). |
required |
end
|
int
|
The ending index (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of elements in the specified range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.lrem
abstractmethod
¶
Removes occurrences of a value from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of occurrences to remove (0 for all). |
required |
value
|
str
|
The value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of elements removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.lset
abstractmethod
¶
Sets the value of an element in a list by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
index
|
int
|
The index to set. |
required |
value
|
str
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.rpop
abstractmethod
¶
Removes and returns the last element(s) of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.rpush
abstractmethod
¶
Pushes one or more values to the end of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.scan
abstractmethod
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Iterates over keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A tuple of (new_cursor, list_of_keys). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.scan_iter
abstractmethod
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator
Provides an iterator over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
An iterator yielding keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.sscan
abstractmethod
¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Iterates over members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the set. |
required |
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A tuple of (new_cursor, list_of_members). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.sscan_iter
abstractmethod
¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator
Provides an iterator over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the set. |
required |
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
An iterator yielding set members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.sadd
abstractmethod
¶
Adds one or more members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of members added (excluding duplicates). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.scard
abstractmethod
¶
Gets the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The cardinality (size) of the set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.sismember
abstractmethod
¶
Checks if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
value
|
str
|
The value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is a member, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.smembers
abstractmethod
¶
Gets all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
A set of all members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.spop
abstractmethod
¶
Removes and returns one or more random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: The popped member(s), or None if the set is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.srem
abstractmethod
¶
Removes one or more members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.sunion
abstractmethod
¶
Gets the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
Name of the first key. |
required |
*args
|
bytes | str
|
Additional key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
A set containing members of the resulting union. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zadd
abstractmethod
¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Adds members with scores to a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
A mapping of members to scores. |
required |
nx
|
bool
|
If True, only add new elements. Defaults to False. |
False
|
xx
|
bool
|
If True, only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
If True, return the number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
If True, increment scores instead of setting. Defaults to False. |
False
|
gt
|
bool
|
If True, only update if new score is greater. Defaults to False. |
False
|
lt
|
bool
|
If True, only update if new score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of elements added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zcard
abstractmethod
¶
Gets the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The cardinality (size) of the sorted set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zcount
abstractmethod
¶
Counts members in a sorted set within a score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
min
|
float | str
|
The minimum score (inclusive). |
required |
max
|
float | str
|
The maximum score (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of members within the score range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zpopmax
abstractmethod
¶
Removes and returns members with the highest scores from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zpopmin
abstractmethod
¶
Removes and returns members with the lowest scores from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zrange
abstractmethod
¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Gets a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
start
|
int
|
The starting index or score (depending on byscore). |
required |
end
|
int
|
The ending index or score (depending on byscore). |
required |
desc
|
bool
|
If True, sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
If True, range by score instead of rank. Defaults to False. |
False
|
bylex
|
bool
|
If True, range by lexicographical order. Defaults to False. |
False
|
offset
|
int
|
Offset for byscore or bylex. |
None
|
num
|
int
|
Number of elements for byscore or bylex. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zrevrange
abstractmethod
¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Gets a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
start
|
int
|
The starting index. |
required |
end
|
int
|
The ending index. |
required |
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zrangebyscore
abstractmethod
¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Gets members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
min
|
float | str
|
The minimum score (inclusive). |
required |
max
|
float | str
|
The maximum score (inclusive). |
required |
start
|
int
|
Starting offset. |
None
|
num
|
int
|
Number of elements to return. |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zrank
abstractmethod
¶
Gets the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The rank (index) of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zrem
abstractmethod
¶
Removes one or more members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zscore
abstractmethod
¶
Gets the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The score of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hdel
abstractmethod
¶
Deletes one or more fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hexists
abstractmethod
¶
Checks if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the field exists, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hget
abstractmethod
¶
Gets the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The value of the field, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hgetall
abstractmethod
¶
Gets all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary of field/value pairs. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hkeys
abstractmethod
¶
Gets all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hlen
abstractmethod
¶
Gets the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hset
abstractmethod
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Sets one or more fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str | bytes
|
A single field to set. |
None
|
value
|
str | bytes
|
The value for the single field. |
None
|
mapping
|
dict
|
A dictionary of field/value pairs. |
None
|
items
|
list
|
A list of field/value pairs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hmget
abstractmethod
¶
Gets the values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
keys
|
list
|
A list of fields to get. |
required |
*args
|
str | bytes
|
Additional fields to get. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of values for the specified fields. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.hvals
abstractmethod
¶
Gets all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of values in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.publish
abstractmethod
¶
Publishes a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
The channel to publish to. |
required |
message
|
bytes | str
|
The message to publish. |
required |
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of subscribers that received the message. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.pubsub_channels
abstractmethod
¶
Lists active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
The pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of active channels. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.zincrby
abstractmethod
¶
Increments the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
amount
|
float
|
The amount to increment by. |
required |
value
|
bytes | str | float
|
The member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new score of the member. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.pubsub
abstractmethod
¶
Returns a pub/sub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pub/sub object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.get_pipeline
abstractmethod
¶
Returns a pipeline object for batching commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
If True, execute commands in a transaction. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding in clustered Redis. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pipeline object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.cluster_info ¶
Get cluster information.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Cluster information or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_nodes ¶
Get cluster nodes information.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Cluster nodes info or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_slots ¶
Get cluster slots mapping.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Slots mapping or None for standalone mode. |
archipy.adapters.redis.ports.RedisPort.cluster_key_slot ¶
Get the hash slot for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to get slot for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Key slot or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Key count or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.RedisPort.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
count
|
int
|
Maximum number of keys to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of keys or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort ¶
Interface for asynchronous Redis operations providing a standardized access pattern.
This interface defines the contract for asynchronous Redis adapters, ensuring consistent implementation of Redis operations across different adapters. It covers all essential Redis functionality including key-value operations, collections (lists, sets, sorted sets, hashes), and pub/sub capabilities.
Implementing classes should provide concrete implementations for all methods, typically by wrapping an asynchronous Redis client library.
Source code in archipy/adapters/redis/ports.py
1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 | |
archipy.adapters.redis.ports.AsyncRedisPort.ping
abstractmethod
async
¶
Tests the connection to the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The response from the server, typically "PONG". |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.pttl
abstractmethod
async
¶
Gets the remaining time to live of a key in milliseconds asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The time to live in milliseconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.incrby
abstractmethod
async
¶
Increments the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key to increment. |
required |
amount
|
int
|
The amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after incrementing. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.set
abstractmethod
async
¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Sets a key to a value with optional expiration and conditions asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key to set. |
required |
value
|
RedisSetType
|
The value to set for the key. |
required |
ex
|
RedisExpiryType
|
Expiration time in seconds or timedelta. |
None
|
px
|
RedisExpiryType
|
Expiration time in milliseconds or timedelta. |
None
|
nx
|
bool
|
If True, set only if the key does not exist. Defaults to False. |
False
|
xx
|
bool
|
If True, set only if the key already exists. Defaults to False. |
False
|
keepttl
|
bool
|
If True, retain the existing TTL. Defaults to False. |
False
|
get
|
bool
|
If True, return the old value before setting. Defaults to False. |
False
|
exat
|
RedisAbsExpiryType
|
Absolute expiration time as Unix timestamp or datetime. |
None
|
pxat
|
RedisAbsExpiryType
|
Absolute expiration time in milliseconds or datetime. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The result of the operation, often "OK" or the old value if get=True. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.get
abstractmethod
async
¶
Retrieves the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to retrieve. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value associated with the key, or None if the key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.mget
abstractmethod
async
¶
Gets the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
A single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of values corresponding to the keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.mset
abstractmethod
async
¶
Sets multiple keys to their respective values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
A mapping of keys to values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Typically "OK" on success. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.keys
abstractmethod
async
¶
Returns all keys matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
The pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of matching keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.getset
abstractmethod
async
¶
Sets a key to a value and returns its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key to set. |
required |
value
|
bytes | str | float
|
The new value to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The old value of the key, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.getdel
abstractmethod
async
¶
Gets the value of a key and deletes it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key to get and delete. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key before deletion, or None if it didn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.exists
abstractmethod
async
¶
Checks if one or more keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to check. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of keys that exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.delete
abstractmethod
async
¶
Deletes one or more keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of keys to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of keys deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.append
abstractmethod
async
¶
Appends a value to a key's string value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key to append to. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The length of the string after appending. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.ttl
abstractmethod
async
¶
Gets the remaining time to live of a key in seconds asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The time to live in seconds, or -1 if no TTL, -2 if key doesn't exist. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.type
abstractmethod
async
¶
Determines the type of value stored at a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The type of the key's value (e.g., "string", "list", etc.). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.llen
abstractmethod
async
¶
Gets the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of items in the list. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.lpop
abstractmethod
async
¶
Removes and returns the first element(s) of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.lpush
abstractmethod
async
¶
Pushes one or more values to the start of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.lrange
abstractmethod
async
¶
Gets a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
start
|
int
|
The starting index (inclusive). |
required |
end
|
int
|
The ending index (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of elements in the specified range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.lrem
abstractmethod
async
¶
Removes occurrences of a value from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of occurrences to remove (0 for all). |
required |
value
|
str
|
The value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of elements removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.lset
abstractmethod
async
¶
Sets the value of an element in a list by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
index
|
int
|
The index to set. |
required |
value
|
str
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.rpop
abstractmethod
async
¶
Removes and returns the last element(s) of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
count
|
int
|
Number of elements to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The popped element(s), or None if the list is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.rpush
abstractmethod
async
¶
Pushes one or more values to the end of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The length of the list after the push. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.scan
abstractmethod
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Iterates over keys in the database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A tuple of (new_cursor, list_of_keys). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.scan_iter
abstractmethod
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator
Provides an iterator over keys in the database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str
|
Pattern to match keys against. |
None
|
count
|
int
|
Hint for number of keys to return per iteration. |
None
|
_type
|
str
|
Filter by type (e.g., "string", "list"). |
None
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
An iterator yielding keys. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.sscan
abstractmethod
async
¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Iterates over members of a set incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the set. |
required |
cursor
|
int
|
The cursor position to start scanning. Defaults to 0. |
0
|
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A tuple of (new_cursor, list_of_members). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.sscan_iter
abstractmethod
async
¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator
Provides an iterator over members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the set. |
required |
match
|
bytes | str
|
Pattern to match members against. |
None
|
count
|
int
|
Hint for number of members to return per iteration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
An iterator yielding set members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.sadd
abstractmethod
async
¶
Adds one or more members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of members added (excluding duplicates). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.scard
abstractmethod
async
¶
Gets the number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The cardinality (size) of the set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.sismember
abstractmethod
async
¶
Checks if a value is a member of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
value
|
str
|
The value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is a member, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.smembers
abstractmethod
async
¶
Gets all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
A set of all members. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.spop
abstractmethod
async
¶
Removes and returns one or more random members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: The popped member(s), or None if the set is empty. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.srem
abstractmethod
async
¶
Removes one or more members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.sunion
abstractmethod
async
¶
Gets the union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
Name of the first key. |
required |
*args
|
bytes | str
|
Additional key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
A set containing members of the resulting union. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zadd
abstractmethod
async
¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Adds members with scores to a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
A mapping of members to scores. |
required |
nx
|
bool
|
If True, only add new elements. Defaults to False. |
False
|
xx
|
bool
|
If True, only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
If True, return the number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
If True, increment scores instead of setting. Defaults to False. |
False
|
gt
|
bool
|
If True, only update if new score is greater. Defaults to False. |
False
|
lt
|
bool
|
If True, only update if new score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of elements added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zcard
abstractmethod
async
¶
Gets the number of members in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key of the sorted set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The cardinality (size) of the sorted set. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zcount
abstractmethod
async
¶
Counts members in a sorted set within a score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
min
|
float | str
|
The minimum score (inclusive). |
required |
max
|
float | str
|
The maximum score (inclusive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of members within the score range. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zpopmax
abstractmethod
async
¶
Removes and returns members with the highest scores from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zpopmin
abstractmethod
async
¶
Removes and returns members with the lowest scores from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
count
|
int
|
Number of members to pop. Defaults to None (pops 1). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of (member, score) tuples popped. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zrange
abstractmethod
async
¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Gets a range of members from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
start
|
int
|
The starting index or score (depending on byscore). |
required |
end
|
int
|
The ending index or score (depending on byscore). |
required |
desc
|
bool
|
If True, sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
If True, range by score instead of rank. Defaults to False. |
False
|
bylex
|
bool
|
If True, range by lexicographical order. Defaults to False. |
False
|
offset
|
int
|
Offset for byscore or bylex. |
None
|
num
|
int
|
Number of elements for byscore or bylex. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zrevrange
abstractmethod
async
¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Gets a range of members from a sorted set in reverse order asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
start
|
int
|
The starting index. |
required |
end
|
int
|
The ending index. |
required |
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zrangebyscore
abstractmethod
async
¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Gets members from a sorted set by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
min
|
float | str
|
The minimum score (inclusive). |
required |
max
|
float | str
|
The maximum score (inclusive). |
required |
start
|
int
|
Starting offset. |
None
|
num
|
int
|
Number of elements to return. |
None
|
withscores
|
bool
|
If True, return scores with members. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of members (and scores if withscores=True). |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zrank
abstractmethod
async
¶
Gets the rank of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to find. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The rank (index) of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zrem
abstractmethod
async
¶
Removes one or more members from a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of members removed. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zscore
abstractmethod
async
¶
Gets the score of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
value
|
bytes | str | float
|
The member to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The score of the member, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hdel
abstractmethod
async
¶
Deletes one or more fields from a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields deleted. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hexists
abstractmethod
async
¶
Checks if a field exists in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the field exists, False otherwise. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hget
abstractmethod
async
¶
Gets the value of a field in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str
|
The field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The value of the field, or None if not found. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hgetall
abstractmethod
async
¶
Gets all fields and values in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary of field/value pairs. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hkeys
abstractmethod
async
¶
Gets all fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hlen
abstractmethod
async
¶
Gets the number of fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hset
abstractmethod
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Sets one or more fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
key
|
str | bytes
|
A single field to set. |
None
|
value
|
str | bytes
|
The value for the single field. |
None
|
mapping
|
dict
|
A dictionary of field/value pairs. |
None
|
items
|
list
|
A list of field/value pairs. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
The number of fields added or updated. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hmget
abstractmethod
async
¶
Gets the values of multiple fields in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
keys
|
list
|
A list of fields to get. |
required |
*args
|
str | bytes
|
Additional fields to get. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of values for the specified fields. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.hvals
abstractmethod
async
¶
Gets all values in a hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key of the hash. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
A list of values in the hash. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.publish
abstractmethod
async
¶
Publishes a message to a channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
The channel to publish to. |
required |
message
|
bytes | str
|
The message to publish. |
required |
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The number of subscribers that received the message. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.pubsub_channels
abstractmethod
async
¶
Lists active channels matching a pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
The pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
A list of active channels. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.zincrby
abstractmethod
async
¶
Increments the score of a member in a sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key of the sorted set. |
required |
amount
|
float
|
The amount to increment by. |
required |
value
|
bytes | str | float
|
The member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new score of the member. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.pubsub
abstractmethod
async
¶
Returns a pub/sub object for subscribing to channels asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments for the underlying implementation. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pub/sub object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.get_pipeline
abstractmethod
async
¶
Returns a pipeline object for batching commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
If True, execute commands in a transaction. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding in clustered Redis. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A pipeline object. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If not implemented by the subclass. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_info
async
¶
Get cluster information asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Cluster information or None for standalone mode. |
archipy.adapters.redis.ports.AsyncRedisPort.cluster_nodes
async
¶
Get cluster nodes information asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Cluster nodes info or None for standalone mode. |
archipy.adapters.redis.ports.AsyncRedisPort.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Slots mapping or None for standalone mode. |
archipy.adapters.redis.ports.AsyncRedisPort.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to get slot for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Key slot or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Key count or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
archipy.adapters.redis.ports.AsyncRedisPort.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slot
|
int
|
The slot number. |
required |
count
|
int
|
Maximum number of keys to return. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of keys or None for standalone mode. |
Source code in archipy/adapters/redis/ports.py
options: show_root_toc_entry: false heading_level: 3
Adapters¶
Concrete Redis adapter wrapping the Redis client with ArchiPy conventions for cache operations, pub/sub, and key-value management.
archipy.adapters.redis.adapters.RedisAdapter ¶
Bases: RedisPort
Adapter for Redis operations providing a standardized interface.
This adapter implements the RedisPort interface to provide a consistent way to interact with Redis, abstracting the underlying Redis client implementation. It supports all common Redis operations including key-value operations, lists, sets, sorted sets, hashes, and pub/sub functionality.
The adapter maintains separate connections for read and write operations, which can be used to implement read replicas for better performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
redis_config
|
RedisConfig
|
Configuration settings for Redis. If None, retrieves from global config. Defaults to None. |
None
|
Source code in archipy/adapters/redis/adapters.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
archipy.adapters.redis.adapters.RedisAdapter.cluster_info ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_nodes ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_slots ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_key_slot ¶
archipy.adapters.redis.adapters.RedisAdapter.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
archipy.adapters.redis.adapters.RedisAdapter.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.pttl ¶
Get the time to live in milliseconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.incrby ¶
Increment the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after increment. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.set ¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Set the value of a key with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
value
|
RedisSetType
|
The value to set. |
required |
ex
|
RedisExpiryType | None
|
Expire time in seconds. |
None
|
px
|
RedisExpiryType | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
RedisAbsExpiryType | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
RedisAbsExpiryType | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Result of the operation. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.get ¶
Get the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.mget ¶
Get the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.mset ¶
Set multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.keys ¶
Find all keys matching the given pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.getset ¶
Set the value of a key and return its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The previous value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.getdel ¶
Get the value of a key and delete it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.exists ¶
Check if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.delete ¶
Delete one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.append ¶
Append a value to a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.ttl ¶
Get the time to live in seconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.type ¶
Determine the type stored at key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.llen ¶
Get the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.lpop ¶
Remove and return elements from the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.lpush ¶
Push elements to the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.lrange ¶
Get a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of elements in the specified range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.lrem ¶
Remove elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.lset ¶
Set the value of an element in a list by its index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.rpop ¶
Remove and return elements from the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.rpush ¶
Push elements to the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.scan ¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Scan keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.scan_iter ¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator
Iterate over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
Iterator over matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.sscan ¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Scan members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.sscan_iter ¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator
Iterate over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
Iterator over set members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.sadd ¶
Add members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements added. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.scard ¶
Get the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.sismember ¶
Check if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is a member, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.smembers ¶
Get all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set of all members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.spop ¶
Remove and return random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.srem ¶
Remove members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.sunion ¶
Get the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zadd ¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Add members to a sorted set with scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
Return number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
Increment existing scores. Defaults to False. |
False
|
gt
|
bool
|
Only update if score is greater. Defaults to False. |
False
|
lt
|
bool
|
Only update if score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zcard ¶
Get the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zcount ¶
Count members in a sorted set with scores in range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zpopmax ¶
Remove and return members with highest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zpopmin ¶
Remove and return members with lowest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zrange ¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Get a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lexicographical order. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zrevrange ¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zrangebyscore ¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zrank ¶
Get the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Rank of the member or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zrem ¶
Remove members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zscore ¶
Get the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Score of the member or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hdel ¶
Delete fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hexists ¶
Check if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if field exists, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hget ¶
Get the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Value of the field or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hgetall ¶
Get all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hkeys ¶
Get all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hlen ¶
Get the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hset ¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Set fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Dictionary of field-value pairs. Defaults to None. |
None
|
items
|
list | None
|
List of field-value pairs. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields set. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hmget ¶
Get values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.hvals ¶
Get all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.publish ¶
Publish a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of subscribers that received the message. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.pubsub_channels ¶
List active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of channel names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.zincrby ¶
Increment the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
New score of the member. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.pubsub ¶
Get a PubSub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
PubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.get_pipeline ¶
Get a pipeline object for executing multiple commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Whether to use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.RedisAdapter.ping ¶
Ping the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
'PONG' if successful. |
archipy.adapters.redis.adapters.AsyncRedisAdapter ¶
Bases: AsyncRedisPort
Async adapter for Redis operations providing a standardized interface.
This adapter implements the AsyncRedisPort interface to provide a consistent way to interact with Redis asynchronously, abstracting the underlying Redis client implementation. It supports all common Redis operations including key-value operations, lists, sets, sorted sets, hashes, and pub/sub functionality.
The adapter maintains separate connections for read and write operations, which can be used to implement read replicas for better performance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
redis_config
|
RedisConfig
|
Configuration settings for Redis. If None, retrieves from global config. Defaults to None. |
None
|
Source code in archipy/adapters/redis/adapters.py
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 | |
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_info
async
¶
Get cluster information asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_nodes
async
¶
Get cluster nodes information asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pttl
async
¶
Get the time to live in milliseconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.incrby
async
¶
Increment the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after increment. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.set
async
¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Set the value of a key with optional expiration asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
value
|
RedisSetType
|
The value to set. |
required |
ex
|
RedisExpiryType | None
|
Expire time in seconds. |
None
|
px
|
RedisExpiryType | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
RedisAbsExpiryType | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
RedisAbsExpiryType | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Result of the operation. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.get
async
¶
Get the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.mget
async
¶
Get the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.mset
async
¶
Set multiple keys to their values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.keys
async
¶
Find all keys matching the pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.getset
async
¶
Set a key's value and return its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The previous value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.getdel
async
¶
Get a key's value and delete it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.exists
async
¶
Check if keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.delete
async
¶
Delete keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.append
async
¶
Append a value to a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.ttl
async
¶
Get the time to live in seconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.type
async
¶
Determine the type stored at key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.llen
async
¶
Get the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lpop
async
¶
Remove and return elements from list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lpush
async
¶
Push elements to list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lrange
async
¶
Get a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of elements in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lrem
async
¶
Remove elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.lset
async
¶
Set list element by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.rpop
async
¶
Remove and return elements from list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.rpush
async
¶
Push elements to list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scan
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Scan keys in database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scan_iter
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator[Any]
Iterate over keys in database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Iterator[Any]
|
Iterator[Any]: Iterator over matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sscan
async
¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Scan set members incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sscan_iter
async
¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator[Any]
Iterate over set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Any]
|
Iterator[Any]: Iterator over set members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sadd
async
¶
Add members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements added. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.scard
async
¶
Get number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sismember
async
¶
Check if value is in set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is member, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.smembers
async
¶
Get all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set of all members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.spop
async
¶
Remove and return random set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.srem
async
¶
Remove members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.sunion
async
¶
Get union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zadd
async
¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Add members to sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing. Defaults to False. |
False
|
ch
|
bool
|
Return changed count. Defaults to False. |
False
|
incr
|
bool
|
Increment scores. Defaults to False. |
False
|
gt
|
bool
|
Only if greater. Defaults to False. |
False
|
lt
|
bool
|
Only if less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zcard
async
¶
Get number of members in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zcount
async
¶
Count members in score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zpopmax
async
¶
Pop highest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zpopmin
async
¶
Pop lowest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrange
async
¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Get range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lex. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrevrange
async
¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get reverse range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrangebyscore
async
¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get members by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrank
async
¶
Get rank of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Rank or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zrem
async
¶
Remove members from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zscore
async
¶
Get score of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Score or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hdel
async
¶
Delete fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hexists
async
¶
Check if field exists in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if exists, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hget
async
¶
Get field value from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hgetall
async
¶
Get all fields and values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hkeys
async
¶
Get all fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hlen
async
¶
Get number of fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hset
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Set fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Field-value pairs dict. Defaults to None. |
None
|
items
|
list | None
|
Field-value pairs list. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields set. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hmget
async
¶
Get multiple field values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.hvals
async
¶
Get all values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.publish
async
¶
Publish message to channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of subscribers received message. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pubsub_channels
async
¶
List active channels matching pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of channel names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.zincrby
async
¶
Increment member score in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
New score of the member. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.pubsub
async
¶
Get PubSub object for channel subscription asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.get_pipeline
async
¶
Get pipeline for multiple commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Sharding hint. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.adapters.AsyncRedisAdapter.ping
async
¶
Ping the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
'PONG' if successful. |
Source code in archipy/adapters/redis/adapters.py
options: show_root_toc_entry: false heading_level: 3
Mocks¶
In-memory mock implementation of the Redis port for use in unit tests and BDD scenarios.
archipy.adapters.redis.mocks.FakeRedisClusterWrapper ¶
Bases: FakeRedis
Wrapper around FakeRedis that adds cluster-specific methods.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_info ¶
Return fake cluster info.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_nodes ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_slots ¶
Return fake cluster slots info.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_keyslot ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_countkeysinslot ¶
archipy.adapters.redis.mocks.FakeRedisClusterWrapper.cluster_get_keys_in_slot ¶
archipy.adapters.redis.mocks.RedisMock ¶
Bases: RedisAdapter
A Redis adapter implementation using fakeredis for testing.
Source code in archipy/adapters/redis/mocks.py
archipy.adapters.redis.mocks.RedisMock.ping ¶
Ping the Redis server.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
'PONG' if successful. |
archipy.adapters.redis.mocks.RedisMock.pttl ¶
Get the time to live in milliseconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.incrby ¶
Increment the integer value of a key by the given amount.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after increment. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.set ¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Set the value of a key with optional expiration and conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
value
|
RedisSetType
|
The value to set. |
required |
ex
|
RedisExpiryType | None
|
Expire time in seconds. |
None
|
px
|
RedisExpiryType | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
RedisAbsExpiryType | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
RedisAbsExpiryType | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Result of the operation. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.get ¶
Get the value of a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.mget ¶
Get the values of multiple keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.mset ¶
Set multiple keys to their respective values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.keys ¶
Find all keys matching the given pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.getset ¶
Set the value of a key and return its old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The previous value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.getdel ¶
Get the value of a key and delete it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.exists ¶
Check if one or more keys exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.delete ¶
Delete one or more keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.append ¶
Append a value to a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.ttl ¶
Get the time to live in seconds for a key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.type ¶
Determine the type stored at key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.llen ¶
Get the length of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.lpop ¶
Remove and return elements from the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.lpush ¶
Push elements to the left of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.lrange ¶
Get a range of elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of elements in the specified range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.lrem ¶
Remove elements from a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.lset ¶
Set the value of an element in a list by its index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.rpop ¶
Remove and return elements from the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.rpush ¶
Push elements to the right of a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.scan ¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Scan keys in the database incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.scan_iter ¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator
Iterate over keys in the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys to return. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
Iterator over matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.sscan ¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Scan members of a set incrementally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.sscan_iter ¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator
Iterate over members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Iterator |
Iterator
|
Iterator over set members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.sadd ¶
Add members to a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements added. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.scard ¶
Get the number of members in a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.sismember ¶
Check if a value is a member of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is a member, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.smembers ¶
Get all members of a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set of all members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.spop ¶
Remove and return random members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.srem ¶
Remove members from a set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.sunion ¶
Get the union of multiple sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zadd ¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Add members to a sorted set with scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing elements. Defaults to False. |
False
|
ch
|
bool
|
Return number of changed elements. Defaults to False. |
False
|
incr
|
bool
|
Increment existing scores. Defaults to False. |
False
|
gt
|
bool
|
Only update if score is greater. Defaults to False. |
False
|
lt
|
bool
|
Only update if score is less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zcard ¶
Get the number of members in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zcount ¶
Count members in a sorted set with scores in range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zpopmax ¶
Remove and return members with highest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zpopmin ¶
Remove and return members with lowest scores from sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zrange ¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Get a range of members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Sort in descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lexicographical order. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zrevrange ¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get a range of members from a sorted set in reverse order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zrangebyscore ¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get members from a sorted set by score range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores in result. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Function to cast scores. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zrank ¶
Get the rank of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Rank of the member or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zrem ¶
Remove members from a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zscore ¶
Get the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Score of the member or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hdel ¶
Delete fields from a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hexists ¶
Check if a field exists in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if field exists, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hget ¶
Get the value of a field in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Value of the field or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hgetall ¶
Get all fields and values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hkeys ¶
Get all fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hlen ¶
Get the number of fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hset ¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Set fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Dictionary of field-value pairs. Defaults to None. |
None
|
items
|
list | None
|
List of field-value pairs. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields set. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hmget ¶
Get values of multiple fields in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.hvals ¶
Get all values in a hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.publish ¶
Publish a message to a channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of subscribers that received the message. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.pubsub_channels ¶
List active channels matching a pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match channels. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of channel names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.zincrby ¶
Increment the score of a member in a sorted set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
New score of the member. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.pubsub ¶
Get a PubSub object for subscribing to channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
PubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.get_pipeline ¶
Get a pipeline object for executing multiple commands.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Whether to use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Hint for sharding. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Pipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.RedisMock.cluster_info ¶
archipy.adapters.redis.mocks.RedisMock.cluster_nodes ¶
archipy.adapters.redis.mocks.RedisMock.cluster_slots ¶
archipy.adapters.redis.mocks.RedisMock.cluster_key_slot ¶
archipy.adapters.redis.mocks.RedisMock.cluster_count_keys_in_slot ¶
Count keys in a specific slot.
archipy.adapters.redis.mocks.RedisMock.cluster_get_keys_in_slot ¶
Get keys in a specific slot.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock ¶
Bases: AsyncRedisAdapter
An async Redis adapter implementation using fakeredis for testing.
Source code in archipy/adapters/redis/mocks.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
archipy.adapters.redis.mocks.AsyncRedisMock.config
instance-attribute
¶
archipy.adapters.redis.mocks.AsyncRedisMock.ping
async
¶
Ping the Redis server asynchronously.
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
'PONG' if successful. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.pttl
async
¶
Get the time to live in milliseconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in milliseconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.incrby
async
¶
Increment the integer value of a key by the given amount asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
amount
|
int
|
Amount to increment by. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The new value after increment. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.set
async
¶
set(
name: RedisKeyType,
value: RedisSetType,
ex: RedisExpiryType | None = None,
px: RedisExpiryType | None = None,
nx: bool = False,
xx: bool = False,
keepttl: bool = False,
get: bool = False,
exat: RedisAbsExpiryType | None = None,
pxat: RedisAbsExpiryType | None = None,
) -> RedisResponseType
Set the value of a key with optional expiration asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The key name. |
required |
value
|
RedisSetType
|
The value to set. |
required |
ex
|
RedisExpiryType | None
|
Expire time in seconds. |
None
|
px
|
RedisExpiryType | None
|
Expire time in milliseconds. |
None
|
nx
|
bool
|
Only set if key doesn't exist. |
False
|
xx
|
bool
|
Only set if key exists. |
False
|
keepttl
|
bool
|
Retain the TTL from the previous value. |
False
|
get
|
bool
|
Return the old value. |
False
|
exat
|
RedisAbsExpiryType | None
|
Absolute expiration time in seconds. |
None
|
pxat
|
RedisAbsExpiryType | None
|
Absolute expiration time in milliseconds. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Result of the operation. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.get
async
¶
Get the value of a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None if not exists. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.mget
async
¶
Get the values of multiple keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType | Iterable[RedisKeyType]
|
Single key or iterable of keys. |
required |
*args
|
bytes | str
|
Additional keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.mset
async
¶
Set multiple keys to their values asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Dictionary of key-value pairs. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Always returns 'OK'. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.keys
async
¶
Find all keys matching the pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match keys against. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.getset
async
¶
Set a key's value and return its old value asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The new value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The previous value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.getdel
async
¶
Get a key's value and delete it asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
The value of the key or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.exists
async
¶
Check if keys exist asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys that exist. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.delete
async
¶
Delete keys asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*names
|
bytes | str
|
Variable number of key names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of keys deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.append
async
¶
Append a value to a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
RedisKeyType
|
The key name. |
required |
value
|
bytes | str | float
|
The value to append. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Length of the string after append. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.ttl
async
¶
Get the time to live in seconds for a key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Time to live in seconds. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.type
async
¶
Determine the type stored at key asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Type of the key's value. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.llen
async
¶
Get the length of a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.lpop
async
¶
Remove and return elements from list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.lpush
async
¶
Push elements to list left asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.lrange
async
¶
Get a range of elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of elements in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.lrem
async
¶
Remove elements from a list asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int
|
Number of occurrences to remove. |
required |
value
|
str
|
Value to remove. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.lset
async
¶
Set list element by index asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
index
|
int
|
Index of the element. |
required |
value
|
str
|
New value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.rpop
async
¶
Remove and return elements from list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
count
|
int | None
|
Number of elements to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Popped element(s) or None if list is empty. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.rpush
async
¶
Push elements to list right asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The key name of the list. |
required |
*values
|
bytes | str | float
|
Values to push. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Length of the list after push. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.scan
async
¶
scan(
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> RedisResponseType
Scan keys in database incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.scan_iter
async
¶
scan_iter(
match: bytes | str | None = None,
count: int | None = None,
_type: str | None = None,
**kwargs: Any,
) -> Iterator[Any]
Iterate over keys in database asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of keys. Defaults to None. |
None
|
_type
|
str | None
|
Filter by type. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
Iterator[Any]
|
Iterator[Any]: Iterator over matching keys. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.sscan
async
¶
sscan(
name: RedisKeyType,
cursor: int = 0,
match: bytes | str | None = None,
count: int | None = None,
) -> RedisResponseType
Scan set members incrementally asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
cursor
|
int
|
Cursor position. Defaults to 0. |
0
|
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Tuple of cursor and list of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.sscan_iter
async
¶
sscan_iter(
name: RedisKeyType,
match: bytes | str | None = None,
count: int | None = None,
) -> Iterator[Any]
Iterate over set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The set key name. |
required |
match
|
bytes | str | None
|
Pattern to match. Defaults to None. |
None
|
count
|
int | None
|
Hint for number of elements. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Iterator[Any]
|
Iterator[Any]: Iterator over set members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.sadd
async
¶
Add members to a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to add. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of elements added. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.scard
async
¶
Get number of members in a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.sismember
async
¶
Check if value is in set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
value
|
str
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if value is member, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.smembers
async
¶
Get all members of a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set of all members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.spop
async
¶
Remove and return random set members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
count
|
int | None
|
Number of members to pop. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
bytes | float | int | str | list | None
|
bytes | float | int | str | list | None: Popped member(s) or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.srem
async
¶
Remove members from a set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.sunion
async
¶
Get union of multiple sets asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
RedisKeyType
|
First set key. |
required |
*args
|
bytes | str
|
Additional set keys. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisSetResponseType |
RedisSetResponseType
|
Set containing union of all sets. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zadd
async
¶
zadd(
name: RedisKeyType,
mapping: Mapping[RedisKeyType, bytes | str | float],
nx: bool = False,
xx: bool = False,
ch: bool = False,
incr: bool = False,
gt: bool = False,
lt: bool = False,
) -> RedisResponseType
Add members to sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
mapping
|
Mapping[RedisKeyType, bytes | str | float]
|
Member-score pairs. |
required |
nx
|
bool
|
Only add new elements. Defaults to False. |
False
|
xx
|
bool
|
Only update existing. Defaults to False. |
False
|
ch
|
bool
|
Return changed count. Defaults to False. |
False
|
incr
|
bool
|
Increment scores. Defaults to False. |
False
|
gt
|
bool
|
Only if greater. Defaults to False. |
False
|
lt
|
bool
|
Only if less. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of elements added or modified. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zcard
async
¶
Get number of members in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
bytes | str
|
The sorted set key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zcount
async
¶
Count members in score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members in range. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zpopmax
async
¶
Pop highest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zpopmin
async
¶
Pop lowest scored members asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
count
|
int | None
|
Number to pop. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of popped member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrange
async
¶
zrange(
name: RedisKeyType,
start: int,
end: int,
desc: bool = False,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
byscore: bool = False,
bylex: bool = False,
offset: int | None = None,
num: int | None = None,
) -> RedisResponseType
Get range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index or score. |
required |
end
|
int
|
End index or score. |
required |
desc
|
bool
|
Descending order. Defaults to False. |
False
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
byscore
|
bool
|
Range by score. Defaults to False. |
False
|
bylex
|
bool
|
Range by lex. Defaults to False. |
False
|
offset
|
int | None
|
Offset for byscore/bylex. Defaults to None. |
None
|
num
|
int | None
|
Count for byscore/bylex. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrevrange
async
¶
zrevrange(
name: RedisKeyType,
start: int,
end: int,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get reverse range from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
start
|
int
|
Start index. |
required |
end
|
int
|
End index. |
required |
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrangebyscore
async
¶
zrangebyscore(
name: RedisKeyType,
min: float | str,
max: float | str,
start: int | None = None,
num: int | None = None,
withscores: bool = False,
score_cast_func: RedisScoreCastType = float,
) -> RedisResponseType
Get members by score range asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
min
|
float | str
|
Minimum score. |
required |
max
|
float | str
|
Maximum score. |
required |
start
|
int | None
|
Offset. Defaults to None. |
None
|
num
|
int | None
|
Count. Defaults to None. |
None
|
withscores
|
bool
|
Include scores. Defaults to False. |
False
|
score_cast_func
|
RedisScoreCastType
|
Score cast function. Defaults to float. |
float
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of members or member-score pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrank
async
¶
Get rank of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to find rank for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Rank or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zrem
async
¶
Remove members from sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
*values
|
bytes | str | float
|
Members to remove. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of members removed. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zscore
async
¶
Get score of member in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
value
|
bytes | str | float
|
Member to get score for. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Score or None if not found. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hdel
async
¶
Delete fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
*keys
|
str | bytes
|
Fields to delete. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields deleted. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hexists
async
¶
Check if field exists in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if exists, False otherwise. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hget
async
¶
Get field value from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str
|
Field to get. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: Value or None. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hgetall
async
¶
Get all fields and values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary of field-value pairs. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hkeys
async
¶
Get all fields from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hlen
async
¶
Get number of fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hset
async
¶
hset(
name: str,
key: str | bytes | None = None,
value: str | bytes | None = None,
mapping: dict | None = None,
items: list | None = None,
) -> RedisIntegerResponseType
Set fields in hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
key
|
str | bytes | None
|
Single field name. Defaults to None. |
None
|
value
|
str | bytes | None
|
Single field value. Defaults to None. |
None
|
mapping
|
dict | None
|
Field-value pairs dict. Defaults to None. |
None
|
items
|
list | None
|
Field-value pairs list. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisIntegerResponseType |
RedisIntegerResponseType
|
Number of fields set. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hmget
async
¶
Get multiple field values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
keys
|
list
|
List of field names. |
required |
*args
|
str | bytes
|
Additional field names. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of field values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.hvals
async
¶
Get all values from hash asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The hash key name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisListResponseType |
RedisListResponseType
|
List of values. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.publish
async
¶
Publish message to channel asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
RedisKeyType
|
Channel name. |
required |
message
|
bytes | str
|
Message to publish. |
required |
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
Number of subscribers received message. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.pubsub_channels
async
¶
List active channels matching pattern asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
RedisPatternType
|
Pattern to match. Defaults to "*". |
'*'
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
List of channel names. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.zincrby
async
¶
Increment member score in sorted set asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
RedisKeyType
|
The sorted set key name. |
required |
amount
|
float
|
Amount to increment by. |
required |
value
|
bytes | str | float
|
Member to increment. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
RedisResponseType |
RedisResponseType
|
New score of the member. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.pubsub
async
¶
Get PubSub object for channel subscription asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPubSub |
PubSub
|
PubSub object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.get_pipeline
async
¶
Get pipeline for multiple commands asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transaction
|
Any
|
Use transactions. Defaults to True. |
True
|
shard_hint
|
Any
|
Sharding hint. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AsyncPipeline |
Pipeline
|
Pipeline object. |
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_info
async
¶
Get cluster information asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_nodes
async
¶
Get cluster nodes information asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_slots
async
¶
Get cluster slots mapping asynchronously.
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_key_slot
async
¶
Get the hash slot for a key asynchronously.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_count_keys_in_slot
async
¶
Count keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapters.py
archipy.adapters.redis.mocks.AsyncRedisMock.cluster_get_keys_in_slot
async
¶
Get keys in a specific slot asynchronously.
Source code in archipy/adapters/redis/adapters.py
options: show_root_toc_entry: false heading_level: 3