• This repository has been archived on 21/Jul/2023
  • Stars
    star
    5,766
  • Rank 7,050 (Top 0.2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 13 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.

Disk LRU Cache

A cache that uses a bounded amount of space on a filesystem. Each cache entry has a string key and a fixed number of values. Each key must match the regex [a-z0-9_-]{1,120}. Values are byte sequences, accessible as streams or files. Each value must be between 0 and Integer.MAX_VALUE bytes in length.

The cache stores its data in a directory on the filesystem. This directory must be exclusive to the cache; the cache may delete or overwrite files from its directory. It is an error for multiple processes to use the same cache directory at the same time.

This cache limits the number of bytes that it will store on the filesystem. When the number of stored bytes exceeds the limit, the cache will remove entries in the background until the limit is satisfied. The limit is not strict: the cache may temporarily exceed it while waiting for files to be deleted. The limit does not include filesystem overhead or the cache journal so space-sensitive applications should set a conservative limit.

Clients call edit to create or update the values of an entry. An entry may have only one editor at one time; if a value is not available to be edited then edit will return null.

  • When an entry is being created it is necessary to supply a full set of values; the empty value should be used as a placeholder if necessary.
  • When an entry is being edited, it is not necessary to supply data for every value; values default to their previous value.

Every edit call must be matched by a call to Editor.commit or Editor.abort. Committing is atomic: a read observes the full set of values as they were before or after the commit, but never a mix of values.

Clients call get to read a snapshot of an entry. The read will observe the value at the time that get was called. Updates and removals after the call do not impact ongoing reads.

This class is tolerant of some I/O errors. If files are missing from the filesystem, the corresponding entries will be dropped from the cache. If an error occurs while writing a cache value, the edit will fail silently. Callers should handle other problems by catching IOException and responding appropriately.

Note: This implementation specifically targets Android compatibility.

Download

Download the latest .jar or grab via Maven:

<dependency>
  <groupId>com.jakewharton</groupId>
  <artifactId>disklrucache</artifactId>
  <version>2.0.2</version>
</dependency>

or Gradle:

compile 'com.jakewharton:disklrucache:2.0.2'

Snapshots of the development version are available in Sonatype's snapshots repository.

If you would like to compile your own version, the library can be built by running mvn clean verify. The output JAR will be in the target/ directory. (Note: this requires Maven be installed)

License

Copyright 2012 Jake Wharton
Copyright 2011 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

butterknife

Bind Android views and callbacks to fields and methods.
Java
25,610
star
2

timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
Kotlin
10,406
star
3

ViewPagerIndicator

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
Java
10,166
star
4

RxBinding

RxJava binding APIs for Android's UI widgets.
Kotlin
9,693
star
5

hugo

Annotation-triggered method call logging for your debug builds.
Java
7,892
star
6

ActionBarSherlock

[DEPRECATED] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.
Java
7,130
star
7

u2020

A sample Android app which showcases advanced usage of Dagger among other open source libraries.
Java
5,682
star
8

pidcat

Colored logcat script which only shows log entries for a specific application package.
Python
4,723
star
9

NineOldAndroids

[DEPRECATED] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!
Java
4,508
star
10

ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Java
3,540
star
11

scalpel

A surgical debugging tool to uncover the layers under your app.
Java
2,770
star
12

RxRelay

RxJava types that are both an Observable and a Consumer.
Java
2,475
star
13

Telecine

Record full-resolution video on your Android devices.
Java
2,472
star
14

kotterknife

View "injection" library for Android.
Kotlin
2,231
star
15

SdkSearch

An Android app and Chrome extension for searching the Android SDK documentation.
Kotlin
2,034
star
16

retrofit2-kotlin-coroutines-adapter

A Retrofit 2 adapter for Kotlin coroutine's Deferred type.
Kotlin
1,961
star
17

ProcessPhoenix

Process Phoenix facilitates restarting your application process.
Java
1,786
star
18

diffuse

Diffuse is a tool for diffing APKs, AABs, AARs, and JARs
Kotlin
1,779
star
19

mosaic

An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime
Kotlin
1,500
star
20

sdk-manager-plugin

DEPRECATED Gradle plugin which downloads and manages your Android SDK.
Groovy
1,414
star
21

Android-DirectionalViewPager

[DEPRECATED] Implementation of the compatibility library ViewPager class that supports paging both vertically and horizontally.
Java
1,038
star
22

DrawerBehavior

A CoordinatorLayout behavior which mimics the functionality of DrawerLayout.
Java
894
star
23

adb-event-mirror

Mirror the touch/key/button events of one device onto one or more other devices in real-time
Kotlin
873
star
24

retrofit2-kotlinx-serialization-converter

A Retrofit 2 Converter.Factory for Kotlin serialization.
Kotlin
848
star
25

picnic

A Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text
Kotlin
838
star
26

retrofit2-rxjava2-adapter

An RxJava 2 CallAdapter.Factory implementation for Retrofit 2.
812
star
27

dependency-tree-diff

An intelligent diff tool for the output of Gradle's dependencies task
Kotlin
704
star
28

wormhole

A time-traveling bytecode rewriter which adds future APIs to android.jar
Kotlin
664
star
29

picasso2-okhttp3-downloader

A OkHttp 3 downloader implementation for Picasso 2.
Java
659
star
30

dagger-reflect

A reflection-based implementation of the Dagger dependency injection library for fast IDE builds.
Java
655
star
31

RxReplayingShare

An RxJava transformer which combines replay(1), publish(), and refCount() operators.
Java
629
star
32

flip-tables

Because pretty-printing text tables in Java should be easy.
Java
609
star
33

SwipeToDismissNOA

Backport of Roman Nurik's "Swipe-to-dismiss" sample code using NineOldAndroids to work on all API levels.
Java
552
star
34

salvage

Generic view recycler and ViewPager PagerAdapter implementation.
Java
467
star
35

okhttp-idling-resource

An Espresso IdlingResource for OkHttp.
Java
459
star
36

madge

A debugging tool to determine whether or not your bitmaps are being drawn at their native resolution.
Java
392
star
37

Reagent

Experiments for future reactive libraries.
Kotlin
364
star
38

double-espresso

[DEPRECATED] A pure Gradle port of the Espresso testing utility for Android!
Java
340
star
39

docker-gphotos-sync

A Docker image for synchronizing your original-quality Google Photos
Shell
336
star
40

gradle-android-test-plugin

[DEPRECATED] A Gradle plugin which enables good 'ol fashioned unit tests for Android builds.
Java
328
star
41

nopen

An error-prone checker which requires that classes be final, abstract or annotated with @ Open.
Java
316
star
42

mkvdts2ac3

Bash script to convert DTS audio to AC3 within a matroska file.
Shell
314
star
43

RxWindowIfChanged

An RxJava 2 operator which splits an observable into windows using a key selector.
Java
307
star
44

OverloadReturn

Bytecode rewriter that creates overloads of methods which vary only by return type.
Kotlin
300
star
45

paraphrase

An experimental Gradle plugin which generates compile-safe format string builders.
Java
281
star
46

gitout

A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere
Rust
259
star
47

dependency-watch

Script to wait for an artifact to appear in a Maven repository or to monitor coordinates for new versions.
Kotlin
240
star
48

confundus

Kotlin compiler plugin which brings Kotlin/JS's unsafeCast to Kotlin/JVM
Kotlin
236
star
49

AutoValueAnnotations

A standalone packaging of the annotations from Google's AutoValue library.
Shell
222
star
50

adjacent-fragment-pager-sample

Demonstrates how to manage two fragments where portrait displays them in a ViewPager and landscape displays them side-by-side.
Java
214
star
51

retrofit1-okhttp3-client

A OkHttp 3 client implementation for Retrofit 1.
Java
194
star
52

retrofit2-reactor-adapter

A Project Reactor CallAdapter.Factory implementation for Retrofit 2.
Java
183
star
53

jardiff

A Python script which quickly creates diffs of the public API between two JAR files
Python
183
star
54

sdk-artifact-sync

A script which synchronizes all of the artifacts in your local Android SDK to a remote Maven artifact host.
Python
182
star
55

dodo

Synchronize your Twitter timeline to a local database for archival and search
Kotlin
182
star
56

shimo

Shimo is an adapter for Moshi which randomizes the order of keys when serializing and deserializing
Java
178
star
57

cite

A Kotlin compiler plugin for embedding information about the file being compiled
Kotlin
178
star
58

PxJava

An experiment which interprets RxJava as an entirely pull-based system written in Kotlin.
Kotlin
173
star
59

HanselAndGretel

Android library providing bread crumbs to the support library fragments.
Java
163
star
60

byteunits

Utility classes for converting between granularities of SI and IEC byte units and bit units.
Kotlin
159
star
61

agp-java-support

Tracking your ability to use new Java language features and APIs in an Android app
Java
151
star
62

crossword

A 2D canvas for rendering text, usually for console applications.
Kotlin
142
star
63

NotificationCompat2

[DEPRECATED] Please use the support library r11 or newer for these features.
Java
132
star
64

dalvik-dx

A standalone packaging of AOSP's platform/dalvik dx library.
Shell
125
star
65

NormallyClosed

Open and close your garage door with a Raspberry Pi
Rust
117
star
66

jakewharton.com

Personal website and blog.
HTML
117
star
67

plex-orphaned-files

Find files in your Plex libraries which are not indexed
Kotlin
114
star
68

AndroidDesignKeynoteTheme

A simple theme for Apple Keynote which adheres to the clean look of the Android Design website.
92
star
69

py-videodownloader

[DEPRECATED] Python module and script for downloading video source files from the major online streaming sites (YouTube, Vimeo, etc.)
Python
90
star
70

jax-rs-moshi

A JAX-RS message body reader/writer and parameter converter which uses Moshi to handle JSON
Java
89
star
71

ActionBarSherlock-Plugin-Maps

[DEPRECATED] Plugin for ActionBarSherlock which provides a base activity that can be used for adding a MapView to your action bar-enabled layouts.
Java
89
star
72

dockerfile-shebang

Treat your Dockerfiles as self-contained, editable scripts
Shell
86
star
73

singular-solution

Keep your Twitter follower count at zero by blocking and then quickly unblocking any new followers
Kotlin
86
star
74

ActivityCompat2

[DEPRECATED] Please use the support library r13 or newer for these features.
Java
76
star
75

docker-mbsync

A Docker container which runs the mbsync tool automatically to synchronize your email
Shell
74
star
76

RxJava2-Java6

An automated backport of RxJava 2 to support Java 6.
Java
73
star
77

PosterBox

Rotating display of Movie and TV posters
Kotlin
72
star
78

jax-rs-kotlinx-serialization

A JAX-RS message body reader/writer and parameter converter which uses Kotlinx Serialization
Kotlin
70
star
79

gradle-like-bazel

A demo showing that you can (probably) structure Gradle projects like you would Bazel
Java
67
star
80

gms-mvn-install

[DEPRECATED] Installs Google Play Services to your local Maven repo or deploys it to a remote repo.
Shell
64
star
81

SMSBarrage

An Android application which allows you send mass repeated SMS messages to any number of contacts.
Java
63
star
82

platform-collections

Kotlin multiplatform collections which use platform-optimized storage
Kotlin
63
star
83

SMSMorse

An Android service that vibrates incoming SMS messages in Morse code.
Java
63
star
84

uniqtoo

A version of `sort | uniq -c` with output that updates in real-time as each line is parsed
Rust
62
star
85

snooker

[DEPRECATED] Please use the support library v20.0.0 or newer for these features.
Java
62
star
86

rebaseandsqua.sh

Utility and website which makes it easy to rebase and squash your branches.
56
star
87

asciinema-vsync

Batch the commands inside an Asciinema JSON file to reduce flickering
Kotlin
56
star
88

ActionBarSherlock-Gradle-Sample

[DEPRECATED] A tiny sample project that uses ActionBarSherlock via Gradle
Groovy
52
star
89

trakt-java

A Java wrapper around the Trakt RESTful API and a simple DSL for easy interaction.
Java
48
star
90

google-maven-exploder

Kotlin
48
star
91

resourcefs

A minimal FileSystem which exposes resources inside the current class loader.
Java
45
star
92

TronWallpaper

An Android live wallpaper which races lightcycles around your icons against Master Control.
Java
45
star
93

dumbo

Import a Twitter archive into a Mastodon database.
Kotlin
40
star
94

ui-spy

Monitor products on the Ubiquiti Store and receive notifications when their availability changes.
Kotlin
40
star
95

twirl-maven-plugin

A Maven plugin which compiles Twirl templates into Scala source files.
Java
40
star
96

uglify-js-middleware

Connect middleware which will automatically uglify your JS files.
JavaScript
38
star
97

SnakeWallpaper

An Android live wallpaper which plays the classic game of snake around your icons. Available on the Android Market.
Java
36
star
98

libcore-dex

A standalone packaging of AOSP's platform/libcore dex library.
Shell
32
star
99

tools-apksig

A standalone packaging of AOSP's platform/tools/apksig library.
28
star
100

WritingAgileAPKs

AnDevCon III Presentation: Writing Agile APKs
Java
26
star