使用 Google App Engine 生成带有实体密钥的短 URL

发布于 2024-07-27 04:28:28 字数 318 浏览 2 评论 0原文

我使用 Google App Engine 和 Google 的 JDO 实现来保存一个实体,我希望为其提供一个 URL,用户可以导航到该 URL 以查看有关该实体的信息。 我遇到的问题是密钥生成策略 IdGeneratorStrategy.IDENTITY 生成非常长的密钥,而 INCREMENT 和 SEQUENCE 策略未实现。 我计划使用密钥作为 URL 的一部分来链接到实体,但是,由于我必须创建系统生成的密钥的唯一选项会导致 URL 变得笨拙,所以我正在寻找如何创建可管理 URL 的建议直接链接到我的数据存储中的实体。

除了创建和维护我自己的 id 生成器之外,还有其他选择吗?

I am using Google App Engine with Google's JDO implementation to save an entity for which I wish to provide an URL that a user can navigate to to view information about that entity. The problem I have is that the key generating strategy IdGeneratorStrategy.IDENTITY produces very long keys while the INCREMENT and SEQUENCE strategies are not implemented. I was planning to use the key as part of the URL to link to the entity, however since the only option I have to create a system generated key would result in an unwieldy URL I'm looking for suggestions how how to create a manageable URL to link directly to an entity in my datastore.

Is there any other option other than to create and maintain my own id generator?

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

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

发布评论

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

评论(1

凉宸 2024-08-03 04:28:28

不要使用整个密钥 - 仅使用 ID 字段。 您可以根据模型名称和 ID 构建密钥。

Don't use the whole key - just the ID field. You can construct a key from the model name and the ID.

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