Code Monkey home page Code Monkey logo

fuse's Introduction

Hello everyone, I'm Kittinun :)

I love Open source and Github is my second home ๐Ÿ 

  • I'm from Bangkok, Thailand but currently based in Tokyo, Japan ๐Ÿ—ผ
  • ๐Ÿ‘จโ€๐Ÿ’ป Long time Android/iOS Engineer with some โค๏ธ for Kotlin & Swift
  • Passionate about building great mobile apps ๐ŸŽ ๐Ÿค–
  • Occassionally, play around with C++, โค๏ธ functional programming and try to be good at it
  • You can find me here ๐Ÿฆ @kittinunf

I am currently looking for Github Sponsor so I can do this more on my free time.

fuse's People

Contributors

babedev avatar eschlenz avatar kittinunf avatar zalewskise avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fuse's Issues

Memory cache sizing

Nice job on the library!

When looking at MemCache.kt, line 9https://github.com/kittinunf/Fuse/blob/master/fuse/src/main/kotlin/com/github/kittinunf/fuse/core/cache/MemCache.kt#L9, I can see that you're setting the size of the cache to 1/8th of the avialable memory, as is described here: https://developer.android.com/topic/performance/graphics/cache-bitmap.html#memory-cache

However, you're not overriding sizeOf, so I believe you'll accept a number of items equal to that value, rather than the number of kilobytes.

Or did I miss something?

integration with Fuel

How can i use this with Fuel. as i want local cache inside my app which have a lot of network calls?

Removing from Cache not working as intended?

Trying to remove a Website from the Cache using Fuse.stringCache.remove(url)
url is the String of the Website I used to download.

However when using it like so I get the following Exception:

 java.lang.IllegalArgumentException: keys must match regex [a-z0-9_-]{1,64}: "https://www.wired.com/2017/11/gifts-for-the-apple-iphone-lover/"
                                                                             at com.jakewharton.disklrucache.DiskLruCache.validateKey(DiskLruCache.java:660)
                                                                             at com.jakewharton.disklrucache.DiskLruCache.remove(DiskLruCache.java:581)
                                                                             at com.github.kittinunf.fuse.core.cache.DiskCache.remove(DiskCache.kt:40)
                                                                             at com.github.kittinunf.fuse.core.Cache.remove(Cache.kt:113)
                                                                             at com.github.kittinunf.fuse.core.Cache.remove$default(Cache.kt:110)

What I tried:

  1. Matching the url to the Regex - did not work as it is not the key
  2. Calling it using Fuse.stringCache.remove(URL(url).toString()) also not finding the Item to remove

What worked was Fuse.stringCache.remove(url.md5()). Is that the way it is supposed to work?
Edit: This did not remove the Value from the Cache

Maybe adding a function to remove Items by URL similar to the get function would be a consideration?

Exposing Put

Is there a reason why put isn't exposed like in any regular caching library?

There're certain use cases where you want to update the cache without getting its content, plus it isn't very convenient when used in conjunction with RxJava given its async nature.

Mem cache reads (hits) should be fast, but are slowed down by disk cache updates.

Hi,

First of all, thanks for open sourcing this project. It's really cool, and easy to use. ๐Ÿ‘

In using this library I have found something that, I believe, is problematic. My expectation is that a mem cache hit should return very quickly. The data is readily available, and nothing else should hold that up.

I believe, however, that even if data is readily available from memory, the library is still doing disk operations before returning this data. It appears to be fully reading the disk cache entry, and then writing it back out in order to bump it up in the LRU cache. https://github.com/kittinunf/Fuse/blob/master/fuse/src/main/java/com/github/kittinunf/fuse/core/Cache.kt#L66-L75

This reading and writing of the entry drastically slows down what should have been a fast operation. And in a situation (like the one I'm in), is extremely noticeable when performing hundreds of cache reads in a short period of time.

I believe what you are trying to do (bump the disk LRU cache entry up) makes sense. I'm just wondering if there is a way that can be done asynchronously, so as not to hold up returning the data that was available from memory.

Thoughts? I'd be happy to collaborate with you on this.

Is there a LruCache bug ?

Hi !
In the Android example the size of Lru cache is set in bytes but the sizeOf method has not been overriden. In this way the LRU size method return the number of element in the LRU cache and not the size in byte.

UnsupportedOperationException

val expiringCache = ExpirableCache(cache)
expiringCache.getWithSource(DeviceDetailsFetcher(), timeLimit = CACHE_PERIOD)

java.lang.UnsupportedOperationException: This function has a reified type parameter and thus can only be inlined at compilation time, not called directly.
at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:207)
at kotlin.jvm.internal.Intrinsics.throwUndefinedForReified(Intrinsics.java:201)
at kotlin.jvm.internal.Intrinsics.reifiedOperationMarker(Intrinsics.java:211)
at com.github.kittinunf.result.Result$Companion.of(Result.kt:244)
at com.github.kittinunf.fuse.core.CacheImpl._get(Cache.kt:74)
at com.github.kittinunf.fuse.core.CacheImpl.getWithSource(Cache.kt:63)
at com.github.kittinunf.fuse.core.scenario.ExpirableCache.getWithSource-8Mi8wO0(ExpirableCache.kt:67)
at com.github.kittinunf.fuse.core.scenario.ExpirableCache.getWithSource-8Mi8wO0$default(ExpirableCache.kt:51)

classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

implementation 'com.github.kittinunf.fuse:fuse-android:1.2.2'

Check for Cached Item

Is there a way to check if an Item with a given Key is currently cached? Or in other words don't perform a network call when it is not cached?

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.