{"id":26830763,"url":"https://github.com/riasatsk/tempdb","last_synced_at":"2026-04-12T00:38:12.636Z","repository":{"id":242246786,"uuid":"809068581","full_name":"riasatsk/tempdb","owner":"riasatsk","description":"⚡A temporary superfast in-memory key-value store with automatic invalidation.","archived":false,"fork":false,"pushed_at":"2024-06-01T15:50:32.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-01T17:56:53.366Z","etag":null,"topics":["bun","database","deno","inmemory-cache","inmemory-db","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://jsr.io/@riasat/tempdb","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riasatsk.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-06-01T15:43:17.000Z","updated_at":"2024-06-01T17:56:57.098Z","dependencies_parsed_at":"2024-06-01T17:56:56.836Z","dependency_job_id":"db2a06ea-7c37-44d6-8c95-df9f1be4a1d1","html_url":"https://github.com/riasatsk/tempdb","commit_stats":null,"previous_names":["riasatsk/tempdb"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riasatsk%2Ftempdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riasatsk%2Ftempdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riasatsk%2Ftempdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riasatsk%2Ftempdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riasatsk","download_url":"https://codeload.github.com/riasatsk/tempdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246326774,"owners_count":20759439,"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":["bun","database","deno","inmemory-cache","inmemory-db","javascript","nodejs","typescript"],"created_at":"2025-03-30T14:17:30.124Z","updated_at":"2026-04-12T00:38:12.604Z","avatar_url":"https://github.com/riasatsk.png","language":"TypeScript","readme":"## **Class: TempDB**\n\nA temporary superfast in-memory key-value store with automatic invalidation.\n\n### **Constructor**\n\n#### `new TempDB(lifeTime: number, invalidationTime: number = 1)`\n\nCreates an instance of TempDB.\n\n* **Parameters:**\n    \n    * `lifeTime` (number): The lifetime of each entry in minutes.\n        \n    * `invalidationTime` (number, optional): The interval for invalidation checks in minutes. Defaults to 1.\n        \n\n### **Methods**\n\n#### `set(key: string, value: any): void`\n\nSets a key-value pair in the TempDB with the current timestamp.\n\n* **Parameters:**\n    \n    * `key` (string): The key for the entry.\n        \n    * `value` (any): The value to be stored.\n        \n\n#### `get(key: string): { data: any; time: number } | undefined`\n\nRetrieves a value from the TempDB by key.\n\n* **Parameters:**\n    \n    * `key` (string): The key for the entry to retrieve.\n        \n* **Returns:**\n    \n    * `{ data: any; time: number } | undefined`: The value associated with the key, or undefined if not found.\n        \n\n### **Usage Example**\n\n```javascript\nimport TempDB from \"@riasat/tempdb\";\n\n// Create a TempDB instance with a lifetime of 1 minute for each entry\nconst db = new TempDB(1);\n\n// Set a key-value pair in the database\ndb.set(\"riasatsk\", 1256);\n\n// Retrieve the value by key\nconsole.log(db.get(\"riasatsk\")); // Output: { data: 1256, time: 1628159995000 }\n\n// Periodically log the entire database to the console\nsetInterval(() =\u003e {\n  console.log(db);\n}, 5000);\n```\n\n### **Notes**\n\n* The `set` method associates a value with a key and records the current timestamp.\n    \n* The `get` method retrieves the value and timestamp for a given key.\n    \n* Entries in the database are automatically invalidated and removed based on the specified `lifeTime`.\n    \n\n### **Loving Message**\n\nThank you for using TempDB! We hope it brings you convenience and joy in your coding journey. Remember to take breaks, stay hydrated, and keep up the great work. Happy coding! ❤️","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friasatsk%2Ftempdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friasatsk%2Ftempdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friasatsk%2Ftempdb/lists"}