{"id":15620790,"url":"https://github.com/simpleton/yasp","last_synced_at":"2025-04-28T13:42:28.221Z","repository":{"id":138799601,"uuid":"127577048","full_name":"simpleton/Yasp","owner":"simpleton","description":"Yet Another Shared Preference","archived":false,"fork":false,"pushed_at":"2018-05-06T23:34:08.000Z","size":577,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T10:11:12.531Z","etag":null,"topics":["android","kvstore","sharedpreferences"],"latest_commit_sha":null,"homepage":"","language":"Java","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/simpleton.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}},"created_at":"2018-03-31T22:41:27.000Z","updated_at":"2020-08-05T13:29:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"b399a3e0-db70-45de-89d8-670a9fcae3b1","html_url":"https://github.com/simpleton/Yasp","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.024390243902439046","last_synced_commit":"cbd539e01607323dd9bd44cdacdb533255b39884"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleton%2FYasp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleton%2FYasp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleton%2FYasp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpleton%2FYasp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simpleton","download_url":"https://codeload.github.com/simpleton/Yasp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251321366,"owners_count":21570726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","kvstore","sharedpreferences"],"created_at":"2024-10-03T09:02:36.146Z","updated_at":"2025-04-28T13:42:28.197Z","avatar_url":"https://github.com/simpleton.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yet Another SharedPreference\n[ ![Download](https://api.bintray.com/packages/simsun/maven/yasp-leveldb/images/download.svg) ](https://bintray.com/simsun/maven/yasp-leveldb/_latestVersion)\n[![Build Status](https://travis-ci.org/simpleton/Yasp.svg?branch=master)](https://travis-ci.org/simpleton/Yasp)\n\nThis library try to introduce a high performance K-V store in Android development to instead of [SharedPreference](https://developer.android.com/reference/android/content/SharedPreferences.html).\n\n## Why\nIf you only need to persist simple values and your application runs in a single process SharedPreferences is probably enough for you. It is a good default option.\n\nThere are some situations where SharedPreferences are not suitable for store KV data:\n\n1. Performance: Your data is complex or there is a lot of it\n2. Multiple thread accessing the data: invoke `editor.appy()` or `editor.commit()` multiple time, even [`apply`](http://aosp.opersys.com/xref/android-8.1.0_r18/xref/frameworks/base/core/java/android/app/SharedPreferencesImpl.java#410) will submit work to other thread.\n3. Multiple processes accessing the data: You have widgets or remote services that run in their own processes and require synchronized data\n\n## Yasp-leveldb\nThis library is wrapped [LevelDB in java](https://github.com/dain/leveldb) with [SharedPreference](https://developer.android.com/reference/android/content/SharedPreferences.html) interface.\n\n### Download\n**Use Gradle:**\n```gradle\nimplementation 'com.simsun.yasp:yasp-leveldb:0.0.3'\n```\n\n### API Usage\nAlmost compat with Android [SharedPreference](https://developer.android.com/reference/android/content/SharedPreferences.html), but there is a little different during initializing.\n\nYasp will **NOT** load whole file when you access one parameter. Feel free to cache yasp instance in your Application.\n\n#### Init\n```java\nSharedPreferences sp = YASPContext.with(Context ct).getSharedPreferences(String name, int mode);\n```\n**Do NOT support multiple processes currently**\n\n#### Get\nAs same as Android [SharedPreference](https://developer.android.com/reference/android/content/SharedPreferences.html)\n```java\nsp.getString(String key, String defaultVal);\n```\n\n#### Editor\nAs same as Android [SharedPreference](https://developer.android.com/reference/android/content/SharedPreferences.html)\n```java\nsp.edit()\n  .putString(String key, String value)\n  .putInt(String key, int value)\n  .apply();\n```\n\n## Benchmark\n// TODO\n\n## Reference\n1. [Best practices in Android development](https://github.com/futurice/android-best-practices#data-storage)\n2. [请不要滥用SharedPreference](http://weishu.me/2016/10/13/sharedpreference-advices/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpleton%2Fyasp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpleton%2Fyasp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpleton%2Fyasp/lists"}