{"id":23790049,"url":"https://github.com/blackglory/cache","last_synced_at":"2026-04-02T02:51:01.391Z","repository":{"id":48913305,"uuid":"479374351","full_name":"BlackGlory/cache","owner":"BlackGlory","description":"🌳","archived":false,"fork":false,"pushed_at":"2025-05-25T08:33:22.000Z","size":790,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-25T09:28:45.679Z","etag":null,"topics":["docker-image","esm","microservice","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/blackglory/cache","language":"TypeScript","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/BlackGlory.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-08T12:04:39.000Z","updated_at":"2025-05-25T08:33:26.000Z","dependencies_parsed_at":"2025-02-21T12:43:28.889Z","dependency_job_id":"ef40ba01-6892-4458-ad6a-5ba322dbd341","html_url":"https://github.com/BlackGlory/cache","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/BlackGlory/cache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/cache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fcache/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006107,"owners_count":26084026,"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-11T02:00:06.511Z","response_time":55,"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":["docker-image","esm","microservice","nodejs","typescript"],"created_at":"2025-01-01T17:18:14.864Z","updated_at":"2026-04-02T02:51:01.363Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cache\n提供以WebSocket为通讯协议的缓存服务, 受到Redis启发.\n\n## Quickstart\n```sh\ndocker run \\\n  --detach \\\n  --publish 8080:8080 \\\n  blackglory/cache\n```\n\n## Install\n### 从源代码运行\n```sh\ngit clone https://github.com/BlackGlory/cache\ncd cache\nyarn install\nyarn build\nyarn bundle\nyarn --silent start\n```\n\n### 从源代码构建\n```sh\ngit clone https://github.com/BlackGlory/cache\ncd cache\nyarn install\nyarn docker:build\n```\n\n### Recipes\n#### docker-compose.yml\n```yaml\nversion: '3.8'\n\nservices:\n  cache:\n    image: 'blackglory/cache'\n    restart: always\n    volumes:\n      - 'cache-data:/data'\n    ports:\n      - '8080:8080'\n\nvolumes:\n  cache-data:\n```\n\n## API\n```ts\ninterface INamespaceStats {\n  items: number\n}\n\ninterface IItem {\n  value: JSONValue\n  metadata: IItemMetadata\n}\n\ninterface IItemMetadata {\n  updatedAt: number\n  timeToLive: number | null\n}\n\ninterface IAPI {\n  getAllNamespaces(): string[]\n  getAllItemKeys(namespace: string): string[]\n\n  getNamespaceStats(namespace: string): INamespaceStats\n\n  hasItem(namespace: string, itemKey: string): boolean\n\n  getItem(namespace: string, itemKey: string): IItem | null\n  getItemValue(namespace: string, itemKey: string): JSONValue | null\n\n  setItem(\n    namespace: string\n  , itemKey: string\n  , itemValue: JSONValue\n  , timeToLive: number | null /* ms */\n  ): null\n\n  removeItem(namespace: string, itemKey: string): null\n\n  clearItemsByNamespace(namespace: string): null\n}\n```\n\n## 环境变量\n### `CACHE_HOST`, `CACHE_PORT`\n通过环境变量`CACHE_HOST`和`CACHE_PORT`决定服务器监听的地址和端口,\n默认值为`localhost`和`8080`.\n\n### `CACHE_WS_HEARTBEAT_INTERVAL`\n通过环境变量`CACHE_WS_HEARTBEAT_INTERVAL`可以设置WS心跳包(ping帧)的发送间隔, 单位为毫秒.\n在默认情况下, 服务不会发送心跳包,\n半开连接的检测依赖于服务端和客户端的运行平台的TCP Keepalive配置.\n\n当`CACHE_WS_HEARTBEAT_INTERVAL`大于零时,\n服务会通过WS的ping帧按间隔发送心跳包.\n\n### `CACHE_MEMORY_CACHE_LRU`\n通过环境变量设置`CACHE_MEMORY_CACHE_LRU`可以设置内存缓存的LRU容量.\n默认值为`0`, 即不使用内存缓存.\n\n## 信号\n### SIGUSR1\n发送SIGUSR1执行heapdump:\n```sh\nkill -SIGUSR1 {pid}\n```\n\n## 客户端\n- JavaScript/TypeScript(Node.js, Browser): \u003chttps://github.com/BlackGlory/cache-js\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fcache/lists"}