DiskLruCache

本文详细介绍了DisLruCache的基本操作方法,包括缓存的创建、编辑、删除等流程,并解释了如何通过Editor进行缓存内容的写入及Snap进行读取的过程。此外,还涉及了缓存状态管理中的一些关键概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Key Elements:
1. DisLruCache
     a. Created by static method DisLruCache.open()
     b. Need to close when you finished write in one piece of cache
     c. If you want to calculate the size of all the cache, call DisLruCache.size()
     d. If you want to delte one cache: call DisLruCache.remove(key)
     e. If you want to delete all the caches, call DisLruCache.delete()
2. Editor
     a. Created by disLruCache.edit(key)
     b. Use commit() if you are sure to write it into cache.
     c. Use abort() if you give up the cache
3. OutputStream
     a. When you write something to cache, you need to get a outputstream, which is got by editor.newOutputStream()
4. Snap
     a. when you read from cache, you first need to get a snap from editor by calling:editor.get(key)
5. InputStream
     a. the input stream is actually where you finally get the cache contents from, which can be got by calling:snapShot.getInputStream(0)

Journal file:
There are several key words:
1. DIRTY: means a record that is not committed
2. CLEAN: means a record has been committed
3. READ: means a record has been read
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值