{"id":26285677,"url":"https://github.com/tans5/tlrucache","last_synced_at":"2026-04-28T19:33:35.223Z","repository":{"id":281162717,"uuid":"944407660","full_name":"Tans5/tLruCache","owner":"Tans5","description":"A Disk \u0026 Memory LRU Cache Library for JVM/Android Inspired by Glide's implementation.","archived":false,"fork":false,"pushed_at":"2025-07-29T08:03:35.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T08:24:52.169Z","etag":null,"topics":["android","disk-cache","jvm","lru-cache","memory-cache"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tans5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-07T09:44:37.000Z","updated_at":"2025-07-29T08:03:39.000Z","dependencies_parsed_at":"2025-07-22T08:37:53.616Z","dependency_job_id":null,"html_url":"https://github.com/Tans5/tLruCache","commit_stats":null,"previous_names":["tans5/tlrucache"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Tans5/tLruCache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tans5%2FtLruCache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tans5%2FtLruCache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tans5%2FtLruCache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tans5%2FtLruCache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tans5","download_url":"https://codeload.github.com/Tans5/tLruCache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tans5%2FtLruCache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32396096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","disk-cache","jvm","lru-cache","memory-cache"],"created_at":"2025-03-14T19:35:55.263Z","updated_at":"2026-04-28T19:33:35.217Z","avatar_url":"https://github.com/Tans5.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nA Disk \u0026 Memory LRU Cache Library for JVM/Android.  \nInspired by [Glide](https://github.com/bumptech/glide)'s implementation.  \n  \n[![](https://img.shields.io/maven-metadata/v.svg?label=maven-central\u0026metadataUrl=https%3A%2F%2Frepo1.maven.org%2Fmaven2%2Fio%2Fgithub%2Ftans5%2Ftlrucache%2Fmaven-metadata.xml)](https://central.sonatype.com/artifact/io.github.tans5/tlrucache)\n  \n## Installation\n\nAdd the dependency to your build.gradle:\n```Groovy\ndependencies {\n\t // ...\n    implementation 'io.github.tans5:tlrucache:1.0.0'\n    // ...\n}\n```\n\n## Usage\n\n### Memory Cache\n\nInitialization\n```Kotlin\n// Create a pool with maximum size of 1024 bytes\nval bytesPool = LruByteArrayPool(1024L)\n```\n\nObtaining and Releasing Buffers\n\n```Kotlin\n// Request a 10-byte buffer\nval buffer = bytesPool.get(10)\nval byteArray = buffer.value\n\n// Use the byte array\n// ...\n\n// Return the buffer to the pool\nbytesPool.put(buffer)\n```\n\nCleanup\n\n```Kotlin\n// Release resources when no longer needed\nbytesPool.release()\n```\n\n### Disk Cache\n\nInitialization\n\n```Kotlin\nval diskCache = DiskLruCache.open(\n    directory = baseDir,    // Base directory for cache files\n    appVersion = 1,        // App version (used for cache invalidation)\n    valueCount = 1,         // Number of files per entry\n    maxSize = 5 * 1024L    // Maximum cache size (5KB)\n)\n```\n\nWriting to Cache\n\n```Kotlin\ndiskCache.edit(key)?.let { editor -\u003e\n    val file = editor.getFile(0).apply {\n        if (!exists()) createNewFile()\n    }\n\n    try {\n        file.outputStream().use { stream -\u003e\n            // Write data to the file\n        }\n        editor.commit()  // Persist changes\n    } catch (e: Throwable) {\n        editor.abort()   // Discard on failure\n    }\n}\n```\n\nReading from Cache\n\n```Kotlin\ndiskCache.get(key)?.let { snapshot -\u003e\n    val file = snapshot.getFile(0)\n    val bytes = file.readBytes()\n    // Process cached data\n}\n```\nClosing the Cache\n\n```Kotlin\ndiskCache.close()\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftans5%2Ftlrucache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftans5%2Ftlrucache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftans5%2Ftlrucache/lists"}