{"id":31943291,"url":"https://github.com/luminus-framework/expiring-map","last_synced_at":"2025-10-14T09:50:50.388Z","repository":{"id":62432623,"uuid":"42285258","full_name":"luminus-framework/expiring-map","owner":"luminus-framework","description":"a thread-safe map that expires entries","archived":false,"fork":false,"pushed_at":"2019-05-25T15:34:08.000Z","size":21,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-20T14:27:17.528Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luminus-framework.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}},"created_at":"2015-09-11T03:24:58.000Z","updated_at":"2022-04-03T19:04:54.000Z","dependencies_parsed_at":"2022-11-01T20:47:12.045Z","dependency_job_id":null,"html_url":"https://github.com/luminus-framework/expiring-map","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luminus-framework/expiring-map","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fexpiring-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fexpiring-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fexpiring-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fexpiring-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luminus-framework","download_url":"https://codeload.github.com/luminus-framework/expiring-map/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminus-framework%2Fexpiring-map/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018554,"owners_count":26086404,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"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":[],"created_at":"2025-10-14T09:50:24.448Z","updated_at":"2025-10-14T09:50:50.378Z","avatar_url":"https://github.com/luminus-framework.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expiring-map\n\nA Clojure wrapper for the [expiringmap](https://github.com/jhalterman/expiringmap).\nThe expiring-map is a thread-safe mutable map that supports expiry for elements.\n\n## Usage\n\n[![Clojars Project](http://clojars.org/expiring-map/latest-version.svg)](http://clojars.org/expiring-map)\n\n### Basic Usage\n\nThe expiry map responds to the standard collection functions such as\n`get`, `count`, `keys`, `vals`, and `empty?`.\n\nIn addition, the map provides the following functions for mutating its values:\n\n* `assoc!` - associates a key value pair with the map\n* `dissoc!` - dissociates a key from the map\n* `clear!` - removes all key/value pairs from the map\n* `reset-expiration!` - resets the expirating timeout for the given key\n\n```clojure\n(require '[expiring-map.core :as em])\n\n(def cache (em/expiring-map 10))\n\n(em/assoc! cache :foo \"bar\")\n\n(get cache :bar)\n(get cache :foo)\n(get cache :bar \"defualt\")\n\n(count cache)\n(vals cache)\n(keys cache)\n(empty? cache)\n\n(em/dissoc! cache :foo)\n\n(em/assoc! cache :foo \"foo\" :bar \"bar\")\n(em/reset-expiration! cache :foo)\n(em/clear! cache)\n```\n\n### Time Units\n\nThe time unit defaults to `:seconds`, the following time units are supported:\n\n* `:nanoseconds`\n* `:microseconds`\n* `:milliseconds`\n* `:seconds`\n* `:minutes`\n* `:hours`\n* `:day`\n\ne.g:\n\n```clojure\n(em/expiring-map 10 {:time-unit :minutes})\n```\n\n### Expiration Policy\n\nThe expiration policy can either be set to creation time or last access, defaults to\ncreation time.\n\n```clojure\n(def cache (em/expiring-map\n            10\n            {:expiration-policy :access\n             :time-unit :minutes}))\n```\n\n### Listeners\n\nThe map allows setting expiry listeners, a listener must be a function that\naccepts the key and the value that expires:\n\n```clojure\n(def cache (em/expiring-map\n            10\n            {:listeners [(fn [k v] (println \"Expired:\" k v))]}))\n```\n\n### Criterium Benchmarks\n\nThe benchmarks below test the assoc/dissoc cycle\nfor the expiring-map, regular atom, and core.cache\natom.\n\n### atom\n```\nWARNING: Final GC required 409.9942905040538 % of runtime\nEvaluation count : 4756014 in 6 samples of 792669 calls.\n             Execution time mean : 120.809576 ns\n    Execution time std-deviation : 2.684070 ns\n   Execution time lower quantile : 118.923613 ns ( 2.5%)\n   Execution time upper quantile : 124.374281 ns (97.5%)\n                   Overhead used : 1.988494 ns\n```\n\n#### expiring-map\n\n```\nWARNING: Final GC required 481.8947027815336 % of runtime\nEvaluation count : 1893510 in 6 samples of 315585 calls.\n             Execution time mean : 322.901037 ns\n    Execution time std-deviation : 11.538941 ns\n   Execution time lower quantile : 313.718453 ns ( 2.5%)\n   Execution time upper quantile : 340.737836 ns (97.5%)\n                   Overhead used : 1.988494 ns\n\nFound 1 outliers in 6 samples (16.6667 %)\n\tlow-severe\t 1 (16.6667 %)\n Variance from outliers : 13.8889 % Variance is moderately inflated by outliers\n```\n\n#### core.cache\n\n```\nWARNING: Final GC required 398.9148954873636 % of runtime\nEvaluation count : 925734 in 6 samples of 154289 calls.\n             Execution time mean : 645.750787 ns\n    Execution time std-deviation : 19.287433 ns\n   Execution time lower quantile : 625.196819 ns ( 2.5%)\n   Execution time upper quantile : 666.538213 ns (97.5%)\n                   Overhead used : 1.988494 ns\n```\n\n## License\n\nCopyright © 2015 Dmitri Sotnikov\n\nDistributed under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminus-framework%2Fexpiring-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluminus-framework%2Fexpiring-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminus-framework%2Fexpiring-map/lists"}