> For the complete documentation index, see [llms.txt](https://docs.zongsoft.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zongsoft.com/framework/core/common/notification.md).

# 通知

Notification 变更令牌工具。

`Notification` 用于创建或获取变更令牌，常与缓存依赖、配置刷新和状态观察配合。

| 成员                                  | 说明                                   |
| ----------------------------------- | ------------------------------------ |
| `Notified`                          | 永远处于已变更状态的令牌。                        |
| `GetToken(CancellationToken)`       | 将可取消令牌包装为变更令牌。                       |
| `GetToken(CancellationTokenSource)` | 从取消源创建变更令牌；传入 `null` 时返回 `Notified`。 |

来源：[framework/Zongsoft.Core/src/Data/DataAccessBase.cs](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Data/DataAccessBase.cs#L120)（节选；上下文见源文件）。

{% code title="DataAccessBase.cs" %}

```csharp
public IChangeToken Disposed => Notification.GetToken(_cancellation);
```

{% endcode %}

上面是框架数据访问器的 Disposed 属性。Discussions 从 Module.Accessor 取得访问器，提供者缓存该访问器时使用此属性作为依赖：释放访问器会触发失效，使下一次取得访问器时重新创建。完整链路见[内存缓存](/framework/core/caching/memory-cache.md)。

Notification 本身不发送业务消息，也不持有重新加载逻辑；它把一次取消通知转换为缓存和配置组件可观察的变更信号。令牌失效后不能复位，需要下一轮观察时应创建新的取消源。

`Notified` 适合表达立即失效的依赖，例如需要强制缓存项创建后即过期的场景。

## 相关资源

* [Notification.cs](https://github.com/Zongsoft/framework/blob/main/Zongsoft.Core/src/Common/Notification.cs)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zongsoft.com/framework/core/common/notification.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
