Git Product home page Git Product logo

androidcachesystem's Introduction

Android通用缓存

本项目是个android上的缓存项目,支持文件缓存和key-value缓存。

使用方法

// 创建一个3级缓存系统
IKeyValueCache cache = new MemCache(new PreferencesCache(new JSONCache(null)));
// save an item
Item item = new Item(1); //也可以是Item(2.5f);Item(true);Item("test");
cache.put("test", item);

// retrieve an int item
int result;
if(cache.isExist("test")) {
    Item item = cache.get("test");
    result = item.asInt();
} else {
    result = 0;
}
// 字符串、浮点、布尔使用方式大同小异

// 创建一个文件缓存,可用来缓存网上下载的图片等资源
IFileCache fileCache = new InternalStorage(new ExternalStorage(null));
// save file
byte[] bytes = bytes of the content;
fileCache.put("test.img", bytes);
// retrieve the file bytes
if(fileCache.isExist("test")){
    bytes = fileCache.get("test");
} else {
    bytes = null;
}

androidcachesystem's People

Contributors

huster-zhangpeng avatar

Stargazers

 avatar

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.