Skip to content

Commit

Permalink
Merge pull request #198 from SiriusCourses/master
Browse files Browse the repository at this point in the history
Add Redis 7.0 compatibility
  • Loading branch information
qnikst authored May 28, 2023
2 parents 736476c + a57b9e3 commit dfabc8a
Show file tree
Hide file tree
Showing 7 changed files with 945 additions and 192 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog for Hedis

## 0.16

- Extended Redis 6 and 7 support.
- add xgroupCreate, xgroupCreateConsumer, xgroupSetId;
- added support of the message trimming by message;
- add support for count parameter for approximate trimming.

Breaking changes:

- **xpendingDetail** instead of 'Maybe ByteString' for a consumer name the method
receives XPendingOpts structure that can take number of milliseconds and consumer name.
In order to preserve an old behavior code should be rewritten as:
xpendingDetails s g f l t Nothing -> xpendingSummary s g f l t defaultXPendingDetailOpts
xpendingDetails s g f l t (Just c) -> xpendingSummary s g f l t defaultXPendingDetailOpts{xPeedingDetailConsumer=Just c)
- **xpendingSummary** no longer accepts consumer arguments as it was done in violation to spec and methodd never worked this way
- **XTrimOpts** type changed, because previous type didn't hold library invariants now instead of a simple ADT XTrimOpts is data that defines strategy of trimming and type, exact or approximate. Here is a conversion table:
NoArg -> is not representable,
In xaddOpts options use Nothing instead;
In xtrim using NoArgs as a bug.
Maxlen n -> TrimOpts{trimOptsStrategy=TrimMaxlen n, trimOptsType=TrimExact};
MaxlenApprox n -> TrimOpts{trumOptsStrategy=TrimMaxlen n, trimOptsType=TrimApprox Nothing};

## 0.15.2

* PR #189. Document that UnixSocket ignores connectHost
Expand Down
26 changes: 26 additions & 0 deletions hedis.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ test-suite hedis-test
if flag(dev)
ghc-prof-options: -auto-all

test-suite redis7
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: MainRedis7.hs
other-modules: PubSubTest
Tests
build-depends:
base == 4.*,
bytestring >= 0.10,
hedis,
HUnit,
async,
stm,
text,
mtl == 2.*,
test-framework,
test-framework-hunit,
time
-- We use -O0 here, since GHC takes *very* long to compile so many constants
ghc-options: -O0 -Wall -rtsopts -fno-warn-unused-do-bind
if flag(dev)
ghc-options: -Werror
if flag(dev)
ghc-prof-options: -auto-all

test-suite hedis-test-cluster
default-language: Haskell2010
type: exitcode-stdio-1.0
Expand Down
90 changes: 80 additions & 10 deletions src/Database/Redis/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ ZaddOpts(..),
defaultZaddOpts,
zadd, -- |Add one or more members to a sorted set, or update its score if it already exists (<http://redis.io/commands/zadd>). The Redis command @ZADD@ is split up into 'zadd', 'zaddOpts'. Since Redis 1.2.0
zaddOpts, -- |Add one or more members to a sorted set, or update its score if it already exists (<http://redis.io/commands/zadd>). The Redis command @ZADD@ is split up into 'zadd', 'zaddOpts'. Since Redis 1.2.0
SizeCondition(..),
zcard, -- |Get the number of members in a sorted set (<http://redis.io/commands/zcard>). Since Redis 1.2.0
zcount, -- |Count the members in a sorted set with scores within the given values (<http://redis.io/commands/zcount>). Since Redis 2.0.0
zincrby, -- |Increment the score of a member in a sorted set (<http://redis.io/commands/zincrby>). Since Redis 1.2.0
Expand Down Expand Up @@ -216,42 +217,88 @@ msetnx, -- |Set multiple keys to multiple values, only if none of the keys exist
psetex, -- |Set the value and expiration in milliseconds of a key (<http://redis.io/commands/psetex>). Since Redis 2.6.0
Condition(..),
SetOpts(..),
set, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts'. Since Redis 1.0.0
setOpts, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts'. Since Redis 1.0.0
set, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setOpts, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setGet, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setGetOpts, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setbit, -- |Sets or clears the bit at offset in the string value stored at key (<http://redis.io/commands/setbit>). Since Redis 2.2.0
setex, -- |Set the value and expiration of a key (<http://redis.io/commands/setex>). Since Redis 2.0.0
setnx, -- |Set the value of a key, only if the key does not exist (<http://redis.io/commands/setnx>). Since Redis 1.0.0
setrange, -- |Overwrite part of a string at key starting at the specified offset (<http://redis.io/commands/setrange>). Since Redis 2.2.0
strlen, -- |Get the length of the value stored in a key (<http://redis.io/commands/strlen>). Since Redis 2.2.0


-- ** Streams
XReadOpts(..),
defaultXreadOpts,
XReadResponse(..),
StreamsRecord(..),
TrimOpts(..),
xadd, -- |Add a value to a stream (<https://redis.io/commands/xadd>). Since Redis 5.0.0
xaddOpts, -- |Add a value to a stream (<https://redis.io/commands/xadd>). The Redis command @XADD@ is split up into 'xadd', 'xaddOpts'. Since Redis 5.0.0
xadd,
xaddOpts,
XAddOpts(..),
defaultXAddOpts,
TrimStrategy(..),
TrimType(..),
TrimOpts(..),
trimOpts,
xread, -- |Read values from a stream (<https://redis.io/commands/xread>). The Redis command @XREAD@ is split up into 'xread', 'xreadOpts'. Since Redis 5.0.0
xreadOpts, -- |Read values from a stream (<https://redis.io/commands/xread>). The Redis command @XREAD@ is split up into 'xread', 'xreadOpts'. Since Redis 5.0.0
xreadGroup, -- |Read values from a stream as part of a consumer group (https://redis.io/commands/xreadgroup). The redis command @XREADGROUP@ is split up into 'xreadGroup' and 'xreadGroupOpts'. Since Redis 5.0.0
xreadGroupOpts, -- |Read values from a stream as part of a consumer group (https://redis.io/commands/xreadgroup). The redis command @XREADGROUP@ is split up into 'xreadGroup' and 'xreadGroupOpts'. Since Redis 5.0.0
xack, -- |Acknowledge receipt of a message as part of a consumer group. Since Redis 5.0.0
xgroupCreate, -- |Create a consumer group. The redis command @XGROUP@ is split up into 'xgroupCreate', 'xgroupSetId', 'xgroupDestroy', and 'xgroupDelConsumer'. Since Redis 5.0.0
xgroupSetId, -- |Set the id for a consumer group. The redis command @XGROUP@ is split up into 'xgroupCreate', 'xgroupSetId', 'xgroupDestroy', and 'xgroupDelConsumer'. Since Redis 5.0.0
xgroupDestroy, -- |Destroy a consumer group. The redis command @XGROUP@ is split up into 'xgroupCreate', 'xgroupSetId', 'xgroupDestroy', and 'xgroupDelConsumer'. Since Redis 5.0.0
xgroupDelConsumer, -- |Delete a consumer. The redis command @XGROUP@ is split up into 'xgroupCreate', 'xgroupSetId', 'xgroupDestroy', and 'xgroupDelConsumer'. Since Redis 5.0.0

-- *** XGROUP CREATE
-- $xgroupCreate
xgroupCreate,
xgroupCreateOpts,
XGroupCreateOpts(..),
defaultXGroupCreateOpts,

-- *** XGROUP CREATECONSUMER
xgroupCreateConsumer,

-- *** XGROUP SETID
-- $xgroupSetId
xgroupSetId,
xgroupSetIdOpts,
XGroupSetIdOpts(..),
defaultXGroupSetIdOpts,

-- *** XGROUP DESTROY
xgroupDestroy,

-- *** XGROUP DELCONSUMER
xgroupDelConsumer,

xrange, -- |Read values from a stream within a range (https://redis.io/commands/xrange). Since Redis 5.0.0
xrevRange, -- |Read values from a stream within a range in reverse order (https://redis.io/commands/xrevrange). Since Redis 5.0.0
xlen, -- |Get the number of entries in a stream (https://redis.io/commands/xlen). Since Redis 5.0.0

-- *** XPENDING
-- $xpending
xpendingSummary,
XPendingSummaryResponse(..),
xpendingSummary, -- |Get information about pending messages (https://redis.io/commands/xpending). The Redis @XPENDING@ command is split into 'xpendingSummary' and 'xpendingDetail'. Since Redis 5.0.0
XPendingDetailOpts(..),
defaultXPendingDetailOpts,
XPendingDetailRecord(..),
xpendingDetail, -- |Get detailed information about pending messages (https://redis.io/commands/xpending). The Redis @XPENDING@ command is split into 'xpendingSummary' and 'xpendingDetail'. Since Redis 5.0.0
xpendingDetail,

XClaimOpts(..),
defaultXClaimOpts,
xclaim, -- |Change ownership of some messages to the given consumer, returning the updated messages. The Redis @XCLAIM@ command is split into 'xclaim' and 'xclaimJustIds'. Since Redis 5.0.0
xclaimJustIds, -- |Change ownership of some messages to the given consumer, returning only the changed message IDs. The Redis @XCLAIM@ command is split into 'xclaim' and 'xclaimJustIds'. Since Redis 5.0.0

-- *** Autoclaim
-- $autoclaim
xautoclaim,
xautoclaimOpts,
XAutoclaimOpts(..),
XAutoclaimStreamsResult,
XAutoclaimResult(..),
xautoclaimJustIds,
xautoclaimJustIdsOpts,
XAutoclaimJustIdsResult,
XInfoConsumersResponse(..),
xinfoConsumers, -- |Get info about consumers in a group. The Redis command @XINFO@ is split into 'xinfoConsumers', 'xinfoGroups', and 'xinfoStream'. Since Redis 5.0.0
XInfoGroupsResponse(..),
Expand Down Expand Up @@ -1093,3 +1140,26 @@ sismember
-> ByteString -- ^ member
-> m (f Bool)
sismember key member = sendRequest (["SISMEMBER"] ++ [encode key] ++ [encode member] )

-- $autoclaim
--
-- Family of the commands related to the autoclaim command in redis, they provide an
-- ability to claim messages that are not processed for a long time.
--
-- Transfers ownership of pending stream entries that match
-- the specified criteria. The message should be pending for more than \<min-idle-time\>
-- milliseconds and ID should be greater than \<start\>.
--
-- Redis @xautoclaim@ command is split info `xautoclaim`, `xautoclaimOpts`, `xautoclaimJustIds`
-- `xautoclaimJustIdsOpt` functions.
--
-- All commands are available since Redis 7.0

-- $xpending
-- The Redis @XPENDING@ command is split into 'xpendingSummary' and 'xpendingDetail'.

-- $xgroupCreate
-- Create a consumer group. The redis command @XGROUP CREATE@ is split up into 'xgroupCreate', 'xgroupCreateOpts'.

-- $xgroupSetId
-- Sets last delivered ID for a consumer group. The redis command @XGROUP SETID@ is split up into 'xgroupSetId' and 'xgroupSetIdOpts' methods.
Loading

0 comments on commit dfabc8a

Please sign in to comment.