简体   繁体   English

在缓存之前,我应该将不同的API调用统一为一种格式吗?

[英]Should I uniform different API calls to a single format before caching?

The problem is that I am recreating the social media widget/icons on http://about.me/bluedaniel (thats me). 问题是我正在http://about.me/bluedaniel (就是我)上重新创建社交媒体小部件/图标。

Anyhow there can be up to 6 or 7 different API calls on the page and obviously I am caching them, at the moment with Memcached. 无论如何,页面上最多可以有6或7个不同的API调用,显然我正在使用Memcached缓存它们。

The question is, as they arrive in various formats and sizes (fb-json, linkedin-xml, wordpress-rss etc), should I universally format/convert them before storing it in the cache. 问题是,由于它们以各种格式和大小(fb-json,linkedin-xml,wordpress-rss等)到达,因此在将其存储在缓存中之前,我是否应该对其进行通用格式/转换。

At present I have recreated the html widget and then stored that, but I worry about saving huge blocks of html in the cache as it doesn't seem that smart. 目前,我已经重新创建了html小部件,然后将其存储,但是我担心在缓存中保存大量的html块,因为它似乎并不聪明。

Doing IO(disc) is expensive. 进行IO(disc)的成本很高。 That's why you should have a copy of the data in memory(memcached). 这就是为什么您应该在内存(memcached)中拥有数据的副本。 But when you have a single data representation in memory then you can without almost any effort do the conversion because it is CPU-bound(CPU is not slowing you down) as long as your not touching the disc. 但是,当您在内存中只有一个数据表示形式时,只要不接触光盘,转换就受CPU限制(CPU不会使您减速),因此您几乎可以毫不费力地进行转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM