Skip to content

Commit d607837

Browse files
committed
Delete and expire event payloads
1 parent 73f10fc commit d607837

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

backend/redis/delete.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import (
1111
// KEYS[1] - instance key
1212
// KEYS[2] - pending events key
1313
// KEYS[3] - history key
14-
// KEYS[4] - instances-by-creation key
14+
// KEYS[4] - payload key
15+
// KEYS[5] - active-instance-execution key
16+
// KEYS[6] - instances-by-creation key
1517
// ARGV[1] - instance segment
1618
var deleteCmd = redis.NewScript(
17-
`redis.call("DEL", KEYS[1], KEYS[2], KEYS[3])
18-
return redis.call("ZREM", KEYS[4], ARGV[1])`)
19+
`redis.call("DEL", KEYS[1], KEYS[2], KEYS[3], KEYS[4], KEYS[5])
20+
return redis.call("ZREM", KEYS[6], ARGV[1])`)
1921

2022
// deleteInstance deletes an instance from Redis. It does not attempt to remove any future events or pending
2123
// workflow tasks. It's assumed that the instance is in the finished state.
@@ -26,6 +28,8 @@ func deleteInstance(ctx context.Context, rdb redis.UniversalClient, instance *co
2628
instanceKey(instance),
2729
pendingEventsKey(instance),
2830
historyKey(instance),
31+
payloadKey(instance),
32+
activeInstanceExecutionKey(instance.InstanceID),
2933
instancesByCreation(),
3034
}, instanceSegment(instance)).Err(); err != nil {
3135
return fmt.Errorf("failed to delete instance: %w", err)

backend/redis/expire.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
// KEYS[3] - instance key
1818
// KEYS[4] - pending events key
1919
// KEYS[5] - history key
20+
// KEYS[6] - payload key
2021
// ARGV[1] - current timestamp
2122
// ARGV[2] - expiration time in seconds
2223
// ARGV[3] - expiration timestamp in unix milliseconds
@@ -55,6 +56,7 @@ func setWorkflowInstanceExpiration(ctx context.Context, rdb redis.UniversalClien
5556
instanceKey(instance),
5657
pendingEventsKey(instance),
5758
historyKey(instance),
59+
payloadKey(instance),
5860
},
5961
nowStr,
6062
expiration.Seconds(),

0 commit comments

Comments
 (0)