{"id":15646787,"url":"https://github.com/healeycodes/in-memory-cache-over-http","last_synced_at":"2026-03-06T14:34:19.622Z","repository":{"id":112378148,"uuid":"214630651","full_name":"healeycodes/in-memory-cache-over-http","owner":"healeycodes","description":"⛷️ In-memory key/value cache server over HTTP with no dependencies.","archived":false,"fork":false,"pushed_at":"2020-08-15T21:56:11.000Z","size":75,"stargazers_count":48,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-12T07:47:49.900Z","etag":null,"topics":["cache","cache-storage","go","golang","in-memory-http-server"],"latest_commit_sha":null,"homepage":"https://healeycodes.com/go/tutorial/beginners/showdev/2019/10/21/cloning-memcached-with-go.html","language":"Go","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/healeycodes.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":"2019-10-12T10:51:24.000Z","updated_at":"2024-08-20T06:06:12.000Z","dependencies_parsed_at":"2023-05-14T03:45:18.657Z","dependency_job_id":null,"html_url":"https://github.com/healeycodes/in-memory-cache-over-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/healeycodes/in-memory-cache-over-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fin-memory-cache-over-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fin-memory-cache-over-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fin-memory-cache-over-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fin-memory-cache-over-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/healeycodes","download_url":"https://codeload.github.com/healeycodes/in-memory-cache-over-http/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/healeycodes%2Fin-memory-cache-over-http/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30180734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T12:39:21.703Z","status":"ssl_error","status_checked_at":"2026-03-06T12:36:09.819Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["cache","cache-storage","go","golang","in-memory-http-server"],"created_at":"2024-10-03T12:14:51.081Z","updated_at":"2026-03-06T14:34:17.542Z","avatar_url":"https://github.com/healeycodes.png","language":"Go","readme":"# ⛷️ in-memory-cache-over-http\n\n\u003e My blog post: [Cloning Memcached with Go](https://healeycodes.com/go/tutorial/beginners/showdev/2019/10/21/cloning-memcached-with-go.html)\n\n\u003cbr\u003e\n\n[![](https://github.com/healeycodes/in-memory-cache-over-http/workflows/Go/badge.svg)](https://github.com/healeycodes/in-memory-cache-over-http/actions?query=workflow%3AGo)\n\n\u003cbr\u003e\n\nAn in-memory key/value cache server over HTTP with no dependencies.\n\nKeys and values are strings. Integer math can be applied in some situations (like Memcached does).\n\nThe caching method is Least Recently Used (LRU).\n\n\u003cbr\u003e\n\n### Install\n\n`go get healeycodes/in-memory-cache-over-http`\n\n\u003cbr\u003e\n\n### Setup\n\n- Set your PORT environmental variable.\n- Set APP_ENV to `production` to turn off logging.\n- Set SIZE to limit the number of key/value pairs, (0 is default - unlimited).\n\n```bash\n# Linux/macOS\nexport PORT=8000\nexport APP_ENV=production\n\n# Command Prompt\nset PORT=8000\nset APP_ENV=production\n\n# PowerShell\n$env:PORT = \"8000\"\n$env:APP_ENV = \"production\"\n```\n\n- Run\n\n`go run .\\main.go`\n\n- Build\n\n`go build`\n\n\u003cbr\u003e\n\n### Usage\n\nAdding an expire parameter is always optional. Not setting it, or setting it to zero means that the key will not expire. It uses **Unix time**.\n\nExample usage.\n\nSet `name` to be `Andrew` with an expire time of `01/01/2030 @ 12:00am (UTC)`\n\nGET `localhost:8000/set?key=name\u0026value=Andrew\u0026expire=1893456000` (204 status code)\n\nRetrieve the value located at `name`.\n\nGET `localhost:8000/get?key=name` (200 status code, body: `Andrew`)\n\n\u003cbr\u003e\n\n### Methods\n\n#### Set (params: key, value, expire) `/set`\n\nSet a key/value. Existing will be overwritten.\n\n\u003cbr\u003e\n\n#### Get `/get`\n\nGet a value from a key.\n\n\u003cbr\u003e\n\n#### Delete (params: key) `/delete`\n\nDelete a key.\n\n\u003cbr\u003e\n\n#### CheckAndSet (params: key, value, expire, compare) `/checkandset`\n\nSet a key/value if the current value at that key matches the compare.\n\nIf no existing key, set the key/value.\n\n\u003cbr\u003e\n\n#### Increment (params: key, value, expire) `/increment`\n\nIncrement a value. Both the existing value and the new value amount should be integers.\n\nIf no existing key, set the key/value.\n\n\u003cbr\u003e\n\n#### Decrement (params: key, value, expire) `/decrement`\n\nDecrement a value. Both the existing value and the new value amount should be integers.\n\nIf no existing key, set the key/value.\n\n\u003cbr\u003e\n\n#### Append (params: key, value, expire) `/append`\n\nConcatenates the new value onto the existing.\n\nIf no existing key, set the key/value.\n\n\u003cbr\u003e\n\n#### Prepend (params: key, value, expire) `/prepend`\n\nConcatenates the existing value onto the new value.\n\nIf no existing key, set the key/value.\n\n\u003cbr\u003e\n\n#### Flush `/flush`\n\nClear the cache. Delete all keys and values.\n\n\u003cbr\u003e\n\n#### Stats `/stats`\n\nReturn statistics about the cache.\n\nExample.\n\n```json\n{\n    \"keyCount\": 1,\n    \"maxSize\": 0\n}\n```\n\n\u003cbr\u003e\n\n### Tests\n\nThe majority of tests are integration tests that test API routes while checking the underlying cache.\n\nThere are some unit tests for the cache.\n\n\u003cbr\u003e\n\nRun tests recursively.\n\n`go test ./...`\n\nExample output.\n\n```bash\n?       healeycodes/in-memory-cache-over-http   [no test files]\nok      healeycodes/in-memory-cache-over-http/api       0.527s\nok      healeycodes/in-memory-cache-over-http/cache     0.340s\n```\n\n\u003cbr\u003e\n\n\n### Contributing\n\nFeel free to raise any issues and pull requests 👍\n\nThere is no road map for this project. My main motivations were to learn more about Go!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhealeycodes%2Fin-memory-cache-over-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhealeycodes%2Fin-memory-cache-over-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhealeycodes%2Fin-memory-cache-over-http/lists"}