Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.
/ mCache Public archive
forked from naseemakhtar994/mCache

Very caching. Such quickly. So reliably. How automagical.

License

Notifications You must be signed in to change notification settings

Glovo/mCache

 
 

Repository files navigation

mCache

How do I use it?

Create it.

via Java:

public class App extends Application {

   @Override
   public void onCreate() {
    super.onCreate();
    Cache
      //.withGlobalMode(CacheMode.FILE)
      .with(this);
  }
}

via Kotlin:

class App : Application() {

  override fun onCreate() {
    super.onCreate()
    Cache
      //.withGlobalMode(CacheMode.FILE)
      .with(this)
  }
}

Save it.

via Java:

User user = new User();
Cache.give(user)
  //.ofIndex(username)
  //.ofMode(mode)
  .build()
  .getNow(); // or .getLater // or .getLaterWithFollowup

via Kotlin:

User().give()
  //.ofIndex { username }
  //.ofMode { mode }
  .build()
  .getNow() // or .getLater // or .getLaterWithFollowup

Get it.

via Java:

Cache.obtain(User.class)
  //.ofIndex(username)
  //.ofMode(mode)
  .build()
  .getNow(); // or .getLater // or .getLaterWithFollowup

via Kotlin:

obtain<User>()
  //.ofIndex { username }
  //.ofMode { mode }
  .build()
  .getNow() // or .getLater // or .getLaterWithFollowup

How easy is that?

Advanced tips

Wrap observables!

Cache.obtain(User::class.java)
  ...
  .getLaterWithFollowup(observable)

Customize

You can redo whole library yourself since it's now made entirely via interfaces.

Contributing

Fork me - make changes - reformat using this code style

Download

Add this to your build.gradle

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.diareuse:mCache:latest.release'
}

Licence

Copyright 2017 Viktor De Pasquale

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.

Created by Viktor De Pasquale in cooperation with Cortex spol. s.r.o.

About

Very caching. Such quickly. So reliably. How automagical.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 97.7%
  • Java 2.3%