# 存储插件数据有什么最佳方式？

**URL:** https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967
**Category:** Development
**Created:** [2025年十一月19日 07:27 UTC](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967 "2025-11-19T07:27:04Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2025年十一月20日 07:15 UTC](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967/13 "2025-11-20T07:15:23Z")

</div>

> [@NateDhaliwal](#):
>
> 我认为 PluginStore 是最合适的方式。站点设置不适合此用例。谢谢！

我认为我们应该弃用 PluginStore，cc @david，它只会带来长期的痛苦。

依我看，创建新表和模型才是正道。

> [@NateDhaliwal](#):
>
> 我的用例是：从启用插件时起创建的任何主题或帖子都会被同步并存储在其他地方。但在此之前的帖子则不会，所以我必须运行一个作业来同步它们，可能分批处理 100 个。我需要存储最低的主题 ID，这样下一批就是该 ID 减去 100，依此类推。

帖子和主题的自定义字段可以实现这一点。缺点是索引可能会很棘手，因为在核心表上添加索引感觉不太对。这又回到了引入新表的问题上。

---

_[View the full topic](https://meta.discourse.org/t/whats-the-best-way-to-store-data-with-a-plugin/388967)._
