Skip to content

Commit

Permalink
docs: update hook doc
Browse files Browse the repository at this point in the history
Signed-off-by: monkey <[email protected]>
  • Loading branch information
monkey92t committed Jan 20, 2023
1 parent 0ed4a44 commit a5aeb16
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ type hooks struct {

// AddHook is to add a hook to the queue.
// Hook is a function executed during network connection, command execution, and pipeline,
// it is a first-in-last-out stack queue (FILO).
// The first to be added to the queue is the execution function of the redis command (the last to be executed).
// it is a first-in-first-out stack queue (FIFO).
// You need to execute the next hook in each hook, unless you want to terminate the execution of the command.
// For example, you added hook-1, hook-2:
//
Expand Down Expand Up @@ -112,10 +111,10 @@ type hooks struct {
//
// The execution sequence is:
//
// hook-2 start -> hook-1 start -> exec redis cmd -> hook-1 end -> hook-2 end
// hook-1 start -> hook-2 start -> exec redis cmd -> hook-2 end -> hook-1 end
//
// Please note: "next(ctx, cmd)" is very important, it will call the next hook,
// if "next(ctx, cmd)" is not executed in hook-1, the redis command will not be executed.
// if "next(ctx, cmd)" is not executed, the redis command will not be executed.
func (hs *hooks) AddHook(hook Hook) {
hs.slice = append(hs.slice, hook)
hs.chain()
Expand Down

0 comments on commit a5aeb16

Please sign in to comment.