Embperl 中 %mdat(与 %udat 相比)的用途是什么?

发布于 2024-10-11 07:22:45 字数 100 浏览 6 评论 0原文

我看到会话处理提到了 %mdat 以及 %udat 哈希。有什么区别以及何时以及为何使用 %mdat 哈希?

I saw that session handling mentioned an %mdat as well as %udat hash. What is the difference and when and why would I use the %mdat hash?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-10-18 07:22:45

正如 Embperl POD 中所述,

您可以在 %mdat 哈希中存储任何数据,如果任何请求到达同一个 Emperl 文档,您将再次在该哈希中看到相同的值。

另外,请注意,上面 POD 中的“您将会看到”措辞有些误导​​性,这可能会导致您感到困惑。

主要 Embperl 文档提供了更多信息消除混乱的精确答案:

下次任何用户访问同一 Emperl 页面时,Embperl 会使用相同的值填充来自 Apache::Session%mdat 哈希值正如您在该页面的最后一个请求中存储的那样。

请注意我以粗体突出显示的文本 - 任何用户。典型的会话数据(存储在 %udat 中)仅特定用户存储和访问。

因此,%mdat 充当一种基于每个 embperl 页面但与用户无关的数据存储。

要回答您的“何时”问题,在实践中使用 %mdat 的一个示例是每页访问计数器。

As noted in Embperl POD,

You can store any data in the %mdat hash and if any request comes to the same Embperl document, you will see the same values in that hash again.

Also, please note that the "you will see" wording in POD above is somewhat misleading, which may have contributed to your confusion.

The main Embperl documentation provides a more precise answer that removes the confusion:

The next time any user hits the same Embperl page, Embperl fill the %mdat hash from Apache::Session with the same values as you have stored within the last request to that page.

Please note the text I highlighted in bold - any user. Typical session data (as stored in %udat) is only stored and accessible for a specific user.

Therefore, %mdat acts as a sort of per-individual-embperl-page but user-independent data store.

To answer your "when" question, an example of using %mdat in practice would be per-page visit counter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文