如何从逻辑上评估在 Joomla 模块中存储小数据的最佳方法?
我正在开发一个新的 Joomla!我需要在其中存储大约 40 个键/值对的只读数据以及关键字和相应的 URL 链接。有多种选择,但我不确定哪一种对程序员方便并且对用户快速加载。或者可能因为数据量很小,所以使用什么方法并不重要。
我可以将这些值硬编码到数组中作为模块代码的一部分。更新不方便,但加载速度很快。
我可以将数据存储在平面文件或 XML 文件中。这将需要额外的代码来实现,并且可以方便地更新列表,但加载速度不如硬编码那么快。
我可以在数据库中创建一个表。 Joomla API 使得使用起来很简单,但我不确定从数据库加载其他所有内容会产生多少开销。
在不尝试每个选项的情况下,如何从逻辑上评估哪一个最有效?
I'm working on a new Joomla! module where I need to store a read-only data of about 40 key/value pairs with a keyword and corresponding URL link. There are several options but I'm not sure which one would be convenient for the programmer and fast-loading for the user. Or maybe because the data amount is so small it doesn't really matter what method is used.
I could hardcode the values into an array as part of the module code. Not convenient to update but it does load fast.
I could store the data in an flat file or XML file. This would require additional code to implement and would be convenient for updating the list, but doesn't load as fast as being hardcoded.
I could create a table in the database. The Joomla API makes this is a no brainer to use but I'm not sure how much overhead there would with everything else being loaded from the database.
How do I logically evaluate which one works best without trying out each of the options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的两个相反的问题是
如果它们更新的次数超过偶尔,那么您最好的选择是将它们放在数据库中,然后 如果您担心的话,可以按某个理想的时间间隔缓存数据。
Your two opposing concerns are
If they're updated more than occasionally, your best bet is to have them in the database and then cache the data at some desirable interval if you're worried about it.