IOS programming image cache module design, ios programming cache Module

Source: Internet
Author: User

IOS programming image cache module design, ios programming cache Module

Why does the mobile client stay? Instead of being replaced by Wap? Because the mobile client has an irreplaceable advantage of Wap, it is its own strong computing capability.

An inevitable part of mobile phones: Image caching is especially important throughout the entire process of software operation.

Let's briefly describe the role of a piece of cache:

Improved response speed: once an image is cached locally, the Read efficiency of local I/O data is much higher than that of network I/O data. Therefore, the response speed can be improved.

Reduce network traffic: in some cases, an image is loaded only once and then not reloaded, reducing network traffic. Reducing traffic is inevitable. Traffic Between China is so expensive, it is necessary

Improve user experience: This experience not only exists in the corresponding speed, but also in some network disconnection modes. Actually, what I want to say is. Even if our computer's hard drive is lost, our software should be robust, not to mention network disconnection.

 

Of course, this will also bring about drawbacks: data synchronization problems, if the data in the network is updated. The data you see locally will always be old data. In fact, I think this is a paradox. This reduces network traffic, which is far greater than the old data. Of course, special software or some situations (Wifi) may require timely data refresh. Load local data first. Load data from the network and replace the cached data. This does not conflict with the data cache. In special cases, it will be better to expire in different time periods. For example, download an image, which is valid within one hour. If it exceeds one hour, it is deemed invalid. Although it is slow, I still see the latest data. As for these policy issues, we should make the most appropriate designs based on different situations. We will not repeat them here. If you are interested, we can also discuss them.

OK. Let's talk about our cache module design. Simply put, it is to map the addresses in the network to the local directory. Simply think about it. It is okay to replace some special fields in the network address. For example, replace "/" with "_" to achieve the purpose of ing. Or directly Save the entries to the local device, it will be OK, but this will lead to other uncertain problems (the length of the network address, if the policy is not good, will there be cache errors. Issues that cannot be implemented in a short period of time ).My approach is to establish a ing relationship directly with a local unique cache address by connecting the network address. And save it to the database along with the Creation Time. In this way, all the above cache effects can be achieved.

Let's take a look at it first, if you need code. Wait.

By the way, I have not mentioned the details. How can I generate a unique local address? See the following methods for reference:

Attach our official website address: http://www.jinhusns.com

You are welcome to reprint it, but please mark it as the original address

 


IOS7 circle of friends album cache location

Jailbreak, find the application location, and find the cache folder.
 
The image link can be cached for up to 24 hours. You cannot store or cache the image itself directly.

The ID address after the image link. You do not need to consider the option. Click the new window to open it. you do not need to consider the image size, height, and width (mainly the module size. On the space homepage, we can adjust it by ourselves), set the module background border, click "NONE", enter the verification code, and click "OK, in the upper left corner of the space, the image module you just created appears (it may be displayed in full gray, but don't worry, the current picture is full gray, do not mistakenly believe that the cross-Inbound operation is unsuccessful ). you can drag the module size to adjust the position you are about to place. at the end of the htt, click "save" at the bottom of the custom page so that the image will be displayed on your space homepage. the effect is demonstrated as follows: The image id I selected is the image name -- Korean exquisite black-and-white dynamic images (240 × 320) a href = ". qqbye/gif/UploadFiles_gif/200805/2008052302393182 .gif" rel = nofollow. qqbye/gif/UploadFiles_gif/200805/2008052302393182 .gif/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.