{"id":14978697,"url":"https://github.com/kaankucukx/nestjs-memoize-endpoint","last_synced_at":"2025-10-28T11:31:48.732Z","repository":{"id":152908973,"uuid":"627555182","full_name":"kaankucukx/nestjs-memoize-endpoint","owner":"kaankucukx","description":"A NestJS decorator that memoizes endpoint results based on the given parameters, improving performance and response times.","archived":false,"fork":false,"pushed_at":"2023-05-16T06:22:15.000Z","size":8724,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T19:52:29.155Z","etag":null,"topics":["api","cache","caching","database","decorator","endpoint","load","memoize","memory","nestjs","optimization","performance","pod","server","time","ttl"],"latest_commit_sha":null,"homepage":"","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/kaankucukx.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":"2023-04-13T17:56:36.000Z","updated_at":"2025-02-22T06:22:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc8d40db-3570-4526-8e2f-071c8b57f8ee","html_url":"https://github.com/kaankucukx/nestjs-memoize-endpoint","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kaankucukx/nestjs-memoize-endpoint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaankucukx%2Fnestjs-memoize-endpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaankucukx%2Fnestjs-memoize-endpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaankucukx%2Fnestjs-memoize-endpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaankucukx%2Fnestjs-memoize-endpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaankucukx","download_url":"https://codeload.github.com/kaankucukx/nestjs-memoize-endpoint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaankucukx%2Fnestjs-memoize-endpoint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281430966,"owners_count":26500238,"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-28T02:00:06.022Z","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":["api","cache","caching","database","decorator","endpoint","load","memoize","memory","nestjs","optimization","performance","pod","server","time","ttl"],"created_at":"2024-09-24T13:58:12.574Z","updated_at":"2025-10-28T11:31:48.726Z","avatar_url":"https://github.com/kaankucukx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NestJS Memoize Endpoint\n\nNestJS Memoize is a simple package that provides a decorator for caching the results of your NestJS endpoints. This can help reduce response time and server load when dealing with slow APIs or databases. The\ndecorator, `Memoize`, allows you to specify how long the results should be stored in the cache.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Basic Example](#basic-example)\n    - [Custom Cache Duration](#custom-cache-duration)\n- [How It Works](#how-it-works)\n\n## Installation\n\nTo install the package, open your terminal or command prompt, navigate to your NestJS project folder, and run the following command:\n\n```bash\nnpm install nestjs-memoize-endpoint\n```\n\nThis command installs the nestjs-memoize-endpoint package into your project, making it available for use.\n\n# Usage\n\nTo use the Memoize decorator in your NestJS project, you'll need to import it and then apply it to the endpoint methods you'd like to cache.\n\n## Basic Example\n\nHere's a simple example showing how to use the Memoize decorator:\n\n````typescript\nimport { Memoize } from 'nestjs-memoize-endpoint';\n\nclass MyController {\n  @Memoize()\n  async getData(): Promise\u003cany\u003e {\n    // Fetch data from a slow API or database\n  }\n}\n\n````\n\nIn this example, we imported the Memoize decorator from the nestjs-memoize-endpoint package and applied it to the getData method. By default, the decorator will cache the results for 5 minutes (300,000 milliseconds).\n\n## Custom Cache Duration\n\nYou can also set a custom cache duration by providing the ttl parameter (time-to-live) in milliseconds. The following example sets the cache duration to 1 minute (60,000 milliseconds):\n\n```typescript\nimport { Memoize } from 'nestjs-memoize-endpoint';\n\nclass MyController {\n  @Memoize(60000) // Cache the result for 1 minute\n  async getData(): Promise\u003cany\u003e {\n    // Fetch data from a slow API or database\n  }\n}\n\n```\n\n## Handling Multiple Parameters\n\nThe Memoize decorator can handle multiple parameters in your endpoint methods. It creates a cache key based on the input parameters, ensuring that each unique combination of parameters gets its own cache entry.\n\nHere's an example with multiple parameters:\n\n````typescript\nimport { Memoize } from 'nestjs-memoize-endpoint';\n\nclass MyController {\n  @Memoize(60000) // Cache the result for 1 minute\n  async getData( param1: string, param2: number ): Promise\u003cany\u003e {\n    // Fetch data from a slow API or database based on the input parameters\n  }\n}\n\n````\n\n## How It Works\n\nWhen you use the Memoize decorator, it checks if there is a cached result for the given method and input parameters. If a cached result exists and it's still within the specified cache duration (the ttl value), the\ndecorator returns the cached result instead of calling the original method.\n\nThis helps reduce the time it takes to respond to requests and can also help reduce the load on your server by avoiding repetitive calls to slow APIs or databases.\n\nRemember to use the Memoize decorator responsibly, as caching can lead to outdated information being returned if the data changes frequently. Use it for endpoints where the data doesn't change often, and the performance\nbenefits outweigh the risk of returning slightly outdated information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaankucukx%2Fnestjs-memoize-endpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaankucukx%2Fnestjs-memoize-endpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaankucukx%2Fnestjs-memoize-endpoint/lists"}