-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for server type specific commands (#340)
- Loading branch information
Showing
15 changed files
with
140 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Any | ||
|
||
from .bitmap_mixin import BitmapCommandsMixin | ||
from .connection_mixin import ConnectionCommandsMixin | ||
from .generic_mixin import GenericCommandsMixin | ||
from .geo_mixin import GeoCommandsMixin | ||
from .hash_mixin import HashCommandsMixin | ||
from .list_mixin import ListCommandsMixin | ||
from .pubsub_mixin import PubSubCommandsMixin | ||
from .server_mixin import ServerCommandsMixin | ||
from .set_mixin import SetCommandsMixin | ||
from .streams_mixin import StreamsCommandsMixin | ||
from .string_mixin import StringCommandsMixin | ||
|
||
try: | ||
from .scripting_mixin import ScriptingCommandsMixin | ||
except ImportError: | ||
|
||
class ScriptingCommandsMixin: # type: ignore # noqa: E303 | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
kwargs.pop("lua_modules", None) | ||
super(ScriptingCommandsMixin, self).__init__(*args, **kwargs) # type: ignore | ||
|
||
|
||
from .transactions_mixin import TransactionsCommandsMixin | ||
|
||
__all__ = [ | ||
"BitmapCommandsMixin", | ||
"ConnectionCommandsMixin", | ||
"GenericCommandsMixin", | ||
"GeoCommandsMixin", | ||
"HashCommandsMixin", | ||
"ListCommandsMixin", | ||
"PubSubCommandsMixin", | ||
"ScriptingCommandsMixin", | ||
"TransactionsCommandsMixin", | ||
"ServerCommandsMixin", | ||
"SetCommandsMixin", | ||
"StreamsCommandsMixin", | ||
"StringCommandsMixin", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from fakeredis.server_specific_commands.dragonfly_mixin import DragonflyCommandsMixin | ||
|
||
__all__ = [ | ||
"DragonflyCommandsMixin", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Callable | ||
|
||
from fakeredis._commands import command, Key, Int, CommandItem | ||
from fakeredis._helpers import Database | ||
|
||
|
||
class DragonflyCommandsMixin(object): | ||
_expireat: Callable[[CommandItem, int], int] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self._db: Database | ||
|
||
@command(name="SADDEX", fixed=(Key(set), Int, bytes), repeat=(bytes,), server_types=("dragonfly",)) | ||
def saddex(self, key: CommandItem, seconds: int, *members: bytes) -> int: | ||
old_size = len(key.value) | ||
key.value.update(members) | ||
key.updated() | ||
self._expireat(key, self._db.time + seconds) | ||
return len(key.value) - old_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters