diff options
Diffstat (limited to 'redis/commands/core.py')
-rw-r--r-- | redis/commands/core.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/redis/commands/core.py b/redis/commands/core.py index 1b8cb80..cef0c28 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -1884,6 +1884,35 @@ class BasicKeyCommands: """ return self.execute_command("UNLINK", *names) + def lcs( + self, + key1: str, + key2: str, + len: Optional[bool] = False, + idx: Optional[bool] = False, + minmatchlen: Optional[int] = 0, + withmatchlen: Optional[bool] = False, + ) -> Union[str, int, list]: + """ + Find the longest common subsequence between ``key1`` and ``key2``. + If ``len`` is true the length of the match will will be returned. + If ``idx`` is true the match position in each strings will be returned. + ``minmatchlen`` restrict the list of matches to the ones of + the given ``minmatchlen``. + If ``withmatchlen`` the length of the match also will be returned. + For more information check https://redis.io/commands/lcs + """ + pieces = [key1, key2] + if len: + pieces.append("LEN") + if idx: + pieces.append("IDX") + if minmatchlen != 0: + pieces.extend(["MINMATCHLEN", minmatchlen]) + if withmatchlen: + pieces.append("WITHMATCHLEN") + return self.execute_command("LCS", *pieces) + class ListCommands: """ |