苹果ios购买收据数据的可能最大长度是多少?
在开始测试 iOS 自动续订购买之前,我需要准备我的服务器数据库。我的问题很简单。我只是想知道数据库中 varchar 字段的大小应该是多少。
Before beginning to test the iOS autorenewing purchases I need to prepare my server database. My question is simple. I just wanna know what size I should make the varchar field in my database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我使用 varchar (4096) 来存储我的 Base64 编码收据。
但说实话,我在官方文档(或其他任何地方)上找不到有关收据长度的任何内容。我唯一找到的Apple 文档 指出收据内容/格式可能会发生变化:
商店收据的内容和格式是私人的,可能会发生变化。您的应用程序不应尝试直接解析收据数据。使用此处描述的机制来验证收据并检索其中存储的信息。
因此,使用文本而不是 varchar 可能确实是最好的选择。
I was using a varchar (4096) to store my base64 encoded receipts.
But to be honest, I couldn't find anything regarding receipt length on the official documentation (or anywhere else). The only thing I did find on Apple's docs was that the receipt content/format is subject to change:
The contents and format of the store receipt is private and subject to change. Your application should not attempt to parse the receipt data directly. Use the mechanism described here to validate the receipt and retrieve the information stored inside it.
So probably going for text instead of varchar really is the best option.
由于包含较旧的订阅信息,
receipt-data
可能会变得更大。实际上,典型大小可能低于 10KB。但由于重复创建新订阅,我在自动化测试中看到了超过 500KB 的收据数据。
最好使用 varchar(max) 或不受限制的文本。
receipt-data
could grow to be much larger due to it containing older subscription information.In practice, typical size is probably under 10KB. But I've seen receipt-data as large as over 500KB in automated testing, due to repeatedly creating new subscriptions.
It's better to use varchar(max) or text where it's not bounded.
在 MySQL 中,使用容量为 16 MB 的 MEDIUMTEXT 是安全的。
我们使用的是 TEXT,但有一次不太适合。
TEXT 的容量只有 64kb,但经过重复交易后,收据大小很可能会超过此大小。我只是在沙盒模式下进行多次交易后才观察到这一点。
In MySQL, it's safe to use MEDIUMTEXT which has capacity 16 MB.
We were using TEXT but didn't fit well at one point.
TEXT has only 64kb capacity but it's more likely that receipt size will be morethan this after repeated transactions. I only observed this after many transaction in sandbox mode.
经过一些简单的数学计算后,我发现使用 MEDIUMTEXT 是安全的,因为每个收据大小以约 2KB/交易的倍数增长,因此您需要超过 800 个交易才能最大化大小。
因此,考虑到 10 年的非常安全的使用期限,每月需要超过 80 笔交易,或者每月大约 7-8 笔交易,这对于大多数用例来说并非如此。
After doing some simple math I figured out it was safe to use MEDIUMTEXT as each receipt size grows by the factor of ~2KB/transaction and so you would need more than 800 transactions to max out the size.
Thus, considering a very safe use span of 10 years it'd require more than 80 transactions a month or roughly 7-8 transactions every month which won't be the case for most use-cases.
可以使用
jsonb
来存储base64。它可以容纳长达 1MB 的数据。May be use
jsonb
to store the base64. It can hold as long as 1MB.