Giter Club home page Giter Club logo

objectcache's Introduction

ObjectCache

Platform Build Status Jitpack

A simple means of storing Objects in Cache.

It uses gson internally to serialize and de-serialize Objects. Its built on top of the awesome DiskLruCache. DiskLruCache has been extended to support explicit eviction of entries based on an expiry.

Note: This implementation specifically targets Android compatibility.

Install

Add jitpack to your root build.gradle

allprojects {
	repositories {
		...
		maven { url "https://jitpack.io" }
	}
}

Add the dependency

dependencies {
	compile 'com.github.myntra:ObjectCache:1.0.0'
}

Usage

Get Instance

Get an instance of ObjectCache. Pass in a cacheDir (File) a folderName (String) along with the appVersion.

ObjectCache.cacheInstance(cacheDir, folder, appVersion);

or

ObjectCache.defaultCache(cacheDir, appVersion);

Write

ObjectCache.cacheInstance(cacheDir, folder, appVersion).write(key, object, expiry);

Fetch

Will return null, if the object has expired

ObjectCache.cacheInstance(cacheDir, folder, appVersion).fetch(key, Class.class);

Fetch Even if Expired

ObjectCache.cacheInstance(cacheDir, folder, appVersion).fetchEvenIfExpired(key, Class.class);

License

ObjectCache is available under the MIT license. See the LICENSE file for more info.

objectcache's People

Contributors

mariostallone avatar nitish24p avatar shrutikagirme avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

objectcache's Issues

SIGSEGV - invalid address on an async thread

Thre's a SIGSEGV crash when the ObjectCache's fetch is invoked from an intent service if the key doesn't match the DiskCache's valid key regex

Can we make ObjectCache's sanitizeKey to throw a RuntimeException if the regex doesn't match and is run on an async?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.