1. Now store the tagged cache data, applying 2 tags: theme_editor, theme_editor_rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW
return Cache::tags([
ThemePreviewInterface::TAG_THEME_EDITOR,
ThemePreviewInterface::TAG_THEME_EDITOR . '_' . $sessionId]
)
->put(ThemePreviewInterface::THEME_EDITOR_SESSION_PREFIX . $sessionId, json_encode($data), ThemePreviewInterface::TTL);
2. After running the program, check the data structure in GUI for Redis. Expand tag. The value of cache:tag:theme_editor:key is: s:22:”633146b13433b471207802″;. This indicates the associated key is: cache:633146b13433b471207802:standard_ref. This is the structure generated by the tag: theme_editor. There are 2 keys in total. As shown in Figure 1

3. After running the program, check the data structure in GUI for Redis. Expand tag. The value of cache:tag:theme_editor_rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW:key is: s:22:”633146b134d67627586383″;. This indicates the associated key is: cache:633146b134d67627586383:standard_ref. This is the structure generated by the tag: theme_editor_rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW. There are 2 keys in total. As shown in Figure 2

4. The lists of keys associated with the 2 tags are identical, yielding the corresponding key: cache:327d4fd2bc91588c8a5e4c7248cf680165a2e12a:theme_editor_session:rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW. As shown in Figure 3

5. Decide to delete the cache data corresponding to cache:327d4fd2bc91588c8a5e4c7248cf680165a2e12a:theme_editor_session:rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW. Do not use the tags method. The operation result is false, indicating deletion failed. As shown in Figure 4

$result = Cache::forget($sessionId);
dd($result);
6. Use the tags method. The operation result is true, indicating successful deletion. As shown in Figure 5

$result = Cache::tags(ThemePreviewInterface::TAG_THEME_EDITOR . '_' . $sessionId)->flush();
dd($result);
7. Check the data in Redis. The associated value list in cache:633146b13433b471207802:standard_ref still has 1 record, not deleted: cache:327d4fd2bc91588c8a5e4c7248cf680165a2e12a:theme_editor_session:rjxMAeCRpPuaD4LJlljDOMXb47hRdVTb2vPW. The key cache:633146b134d67627586383:standard_ref has been deleted, and the key corresponding to the 1 record in its associated value list has also been deleted. This matches expectations. As shown in Figure 6

