{"id":21206202,"url":"https://github.com/rtmigo/fmap_dart","last_synced_at":"2026-04-18T04:02:55.510Z","repository":{"id":61973509,"uuid":"346392155","full_name":"rtmigo/fmap_dart","owner":"rtmigo","description":"Dart library for caching or persistent blob storage. All the data kept in files and accessed with a Map-like object","archived":false,"fork":false,"pushed_at":"2021-04-01T20:12:51.000Z","size":267,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-09T01:56:44.955Z","etag":null,"topics":["blob","cache","caching","dart","dart-library","file-based-cache","file-storage","files","filesystem","flutter","persistent-storage","pubdev","storage"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/fmap","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rtmigo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-10T14:57:41.000Z","updated_at":"2022-02-19T19:43:28.000Z","dependencies_parsed_at":"2022-10-24T13:30:48.213Z","dependency_job_id":null,"html_url":"https://github.com/rtmigo/fmap_dart","commit_stats":null,"previous_names":["rtmigo/fmap"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/rtmigo/fmap_dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Ffmap_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Ffmap_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Ffmap_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Ffmap_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rtmigo","download_url":"https://codeload.github.com/rtmigo/fmap_dart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rtmigo%2Ffmap_dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["blob","cache","caching","dart","dart-library","file-based-cache","file-storage","files","filesystem","flutter","persistent-storage","pubdev","storage"],"created_at":"2024-11-20T20:54:46.718Z","updated_at":"2026-04-18T04:02:55.442Z","avatar_url":"https://github.com/rtmigo.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Pub Package](https://img.shields.io/pub/v/fmap.svg)](https://pub.dev/packages/fmap)\n[![pub points](https://badges.bar/fmap/pub%20points)](https://pub.dev/fmap/tabular/score)\n![Generic badge](https://img.shields.io/badge/tested_on-macOS_|_Ubuntu_|_Windows-blue.svg)\n\n# [fmap](https://github.com/rtmigo/fmap)\n\nA simple and efficient approach to caching or persistent blob storage. Map-like\nobject for accessing data stored on the filesystem.\n\n``` dart\nvar fmap = Fmap(directory);\n\nfmap['keyA'] = 'my string';         // saved string into a file\nfmap['keyB'] = 777;                 // saved int into a file\nfmap['keyC'] = [0x12, 0x34, 0x56];  // saved three-bytes into a file\n\nprint(fmap['keyA']); // read from file\n```\n\n`Fmap` implements a `Map`, so it can be used the same way.\n\n``` dart\nprint('Count of items: ${fmap.length}');\n\nfor (var entry in fmap.entries) {\n    print('Item ${entry.key}: ${entry.value}'); \n}\n```\n\nEntries are stored in separate files. Therefore, reading/writing an entry is\nabout as fast as reading/writing a file with a known exact name. But unlike\ndirect file access, `Fmap` has no restrictions on the content of `String` keys,\nit takes care of finding unique file names, resolving hash collisions, and\nserialization.\n\n## Creating\n\nFor persistent data storage\n\n``` dart\nvar fmap = Fmap(Directory('/path/to/my_precious_data'));\n```\n\nTo cache data in the system temporary directory\n\n``` dart\nvar fmap = Fmap.temp(); // will be placed into {temp}/fmap dir\n```\n\nTo cache data in a specific subdirectory of the system temporary directory\n\n``` dart\nvar images = Fmap.temp(subdir: 'images_cache'); // {temp}/images_cache\nvar jsons  = Fmap.temp(subdir: 'jsons_cache');  // {temp}/jsons_cache\n```\n\nIf all the storage items have the same type, you can set the type with generics\n\n``` dart\nvar strings1 = Fmap\u003cString\u003e(directory);\nvar strings2 = Fmap.temp\u003cString\u003e();\n```\n\n\n## Types\n\nThe collection allows you to store only values of certain types. \nSupported types are `String`, `List\u003cint\u003e`, `List\u003cString\u003e`, `int`, `double` \nand `bool`.\n\n``` dart\nvar fmap = Fmap(directory);\nfmap['string'] = 'abcd';\nfmap['int'] = 5;\nfmap['double'] = 5.0; \nfmap['bool'] = true;\n```\n\n### Bytes\n\nAny `List\u003cint\u003e` is treated as list of bytes.\n\n``` dart\nfmap['blob1'] = [0x12, 0x34, 0x56]; // List\u003cint\u003e\nfmap['blob2'] = utf8.encode('my string'); // List\u003cint\u003e\nfmap['blob3'] = myFile.readAsBytesSync(); // Uint8List implements List\u003cint\u003e \n```\n\nSince numbers are bytes, each `int` inside a list is truncated to the range\n0..255.\n\n``` dart\nfmap['blob4'] = [1, 10, -1, 777]; // saves 1, 10, 255, 9 \n```\n\nLists of bytes always return `Uint8List` when read.\n\n``` dart\nUint8List bytes = fmap['blob4']; // was List\u003cint\u003e, now Uint8List  \n```\n\n\n### String lists\n\nLists of strings, when stored, can be specified by any object that implements \n`Iterable \u003cString\u003e`, not necessarily a `List`.\n\n``` dart\nfmap['saved_list'] = ['ordered', 'strings', 'in', 'list'];\nfmap['saved_iterable'] = {'unordered', 'strings', 'in', 'a', 'set'}; \n```\n\nHowever, when read, they will definitely return as `List\u003cString\u003e`.\n\n``` dart\nList\u003cString\u003e a = fmap['saved_list'];\nList\u003cString\u003e b = fmap['saved_iterable'];\n```\n\n### Entry ~ file\n\nKeep in mind that each entry is saved in a separate file. Therefore, storing a\nlot of atomic values like `double` associated  with different keys may not be\nvery practical. Conversely, saving large objects such as `String`, `List\u003cint\u003e`,\nor `List\u003cString\u003e` is efficient. It's almost like writing directly to files, but\nwithout restrictions on key names.\n\n\n## Purging\n\nIf the storage has become too large, you can delete the oldest data.\n\n``` dart\n// leave only the newest 16 megabytes\nfmap.purge(16*1024*1024);\n```\n\nWhich elements are removed depends on the `policy` argument passed to the \nconstructor.\n\n``` dart\nvar fmap = Fmap(dir, policy: Policy.fifo);\n```\n\nTwo policies are supported: FIFO and LRU. By default, this is FIFO.\n\nIf you want the `purge` method to purge storage with LRU policy, you must\nnot only create `Fmap(policy: Policy.lru)` before purging but always\ncreate the object this way. It will force `Fmap` to update the last-used \ntimestamps every time an entry is read.\n\nWhen you do not specify this argument, the timestamps are only updated on \nwrites, but not on reads.\n\n## Compatibility\n\nThe library is unit-tested on Linux, Windows, and macOS. Mobile systems such as \nAndroid and iOS have the same kernels as their desktop relatives. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Ffmap_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frtmigo%2Ffmap_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frtmigo%2Ffmap_dart/lists"}