Implementation of Android Big data cache strategy based on Java LinkedList

Source: Internet
Author: User

Import Java.util.hashmap;import java.util.linkedlist;/* * Android Big Data cache strategy based on Java LinkedList * Original source:/http Blog.csdn.net/zhangphil * * Implementation principle: The principle of the model that: in the linkedlist of the head element is the oldest cache data, at the end of LinkedList is the latest cache data. * Maintain a storage stack in a linkedlist (linked list of type C), add elements in order, and add them sequentially. * * Principle implementation of the specific scheme: whenever the cached Get () method is called, the element is immediately updated from its original location in LinkedList to the last position of LinkedList. * For example, originally: 1,2,3,4,5. When get is 2, the order is now: 1,3,4,5,2.  * * When the cache space is full, delete the oldest element (at the head) to make room. * For example, the cache space is 5, the original cache has already cached 5 elements: a,b,c,d,e, * When the element f is added again, because the cache space is 5 no more than 6 elements, so delete the head of the element A, the F appended to the tail into: b,c,d,e,f * * Specific use: Similar to Android LRUCache, publicly disclosed two common (generic, means can save bitmap or similar data) method for storage and read use: * public void put (String key, Object obj); *public Object get (String key); * Generic <key,value> storage and reading model. Note: The user should ensure that the key is unique when stored. * */public class Cachebasedonlinkedlist {//capacity default cache capacity private static int capacity = 30;private Linkedlist

Implementation of Android Big data cache strategy based on Java LinkedList

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.