Qachee Library

Qachee is a generic cache system to use specially for Android Apps.

License

License

GroupId

GroupId

com.github.nicolasjafelle
ArtifactId

ArtifactId

qachee
Last Version

Last Version

1.2
Release Date

Release Date

Type

Type

aar
Description

Description

Qachee Library
Qachee is a generic cache system to use specially for Android Apps.
Project URL

Project URL

https://github.com/nicolasjafelle/Qachee
Source Code Management

Source Code Management

https://github.com/nicolasjafelle/Qachee

Download qachee

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.nicolasjafelle/qachee/ -->
<dependency>
    <groupId>com.github.nicolasjafelle</groupId>
    <artifactId>qachee</artifactId>
    <version>1.2</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.nicolasjafelle/qachee/
implementation 'com.github.nicolasjafelle:qachee:1.2'
// https://jarcasting.com/artifacts/com.github.nicolasjafelle/qachee/
implementation ("com.github.nicolasjafelle:qachee:1.2")
'com.github.nicolasjafelle:qachee:aar:1.2'
<dependency org="com.github.nicolasjafelle" name="qachee" rev="1.2">
  <artifact name="qachee" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.nicolasjafelle', module='qachee', version='1.2')
)
libraryDependencies += "com.github.nicolasjafelle" % "qachee" % "1.2"
[com.github.nicolasjafelle/qachee "1.2"]

Dependencies

compile (1)

Group / Artifact Type Version
com.android.support » support-v4 jar 21.0.3

Project Modules

There are no modules declared in this project.

Qachee-logoQachee

Android Arsenal

Qachee is a generic cache system to use specially for Android Apps. It is just a LRU Memory cache with policy expiration and lots of useful methods.

Instructions - Maven Central

  1. Add this library in your build.gradle:
dependencies {
    compile 'com.github.nicolasjafelle:qachee:1.2'
}

Instructions - Android Library Module

  1. Clone the git repo
  2. Import the "Qachee" module into your Android-gradle project.
  3. Add "Qachee" module in your settings.gradle
  4. DONE

How to Use it

First you need to extends the QacheeableObject which implements the Qacheeable interface, then you have to implements getKey, you can return a String value or anything that make your instance unique, like getClass().getSimpleName() + hashcode()

@Override
public String getKey() {
	Log.i("HASHCHODE", "KEY VALUE FOR " + getName() + "= " + getClass().getSimpleName() + hashCode());
	return getClass().getSimpleName() + hashCode();
}

You can set the Expiration Time Policy, default is:

ExpirationTime.ONE_MINUTE 

Simple in your Application or any place use:

QacheeManager.getInstance().setExpirationTime(ExpirationTime.THIRTY_SECONDS);

Then just simple use QacheeManager to add, remove and get your Qacheeable objects.

Character character = QacheeManager.getInstance().get(getItem(position), Character.class, true);

OR...

// If toArray() returns empty means: there is nothing previously stored.
// If toArray() returns null the stored data is no longer valid.
List<Character> list = QacheeManager.getInstance().toArray(Character.class, true);

if(list == null || list.isEmpty()) {
	new DemoTask(getActivity()).execute();
}else {
	adapter = new CharacterAdapter(list);
	listView.setAdapter(adapter);
}

When your object is stored in the Qachee you do not need to re-add or update it, simple use it. REMEMBER always to check if the object is stored in Qachee, REMEMBER always work with Qachee, like this:

Character selectedCharacter = (Character) listView.getItemAtPosition(pos);
selectedCharacter = (Character) QacheeManager.getInstance().get(selectedCharacter, true);

See Demo Sample

Google Play demo: link

Developed By

License

Copyright 2014 Nicolas Jafelle

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.

Versions

Version
1.2
1.1
1.0