{"id":22166234,"url":"https://github.com/maxerbox/command-caching-fisherman","last_synced_at":"2025-08-26T14:22:19.633Z","repository":{"id":57204024,"uuid":"98916514","full_name":"maxerbox/command-caching-fisherman","owner":"maxerbox","description":"A command caching middleware, used to cache the result of a command","archived":false,"fork":false,"pushed_at":"2017-08-01T14:13:28.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T07:54:12.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxerbox.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":"2017-07-31T18:16:43.000Z","updated_at":"2017-07-31T18:19:50.000Z","dependencies_parsed_at":"2022-09-18T01:11:24.150Z","dependency_job_id":null,"html_url":"https://github.com/maxerbox/command-caching-fisherman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-caching-fisherman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-caching-fisherman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-caching-fisherman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-caching-fisherman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxerbox","download_url":"https://codeload.github.com/maxerbox/command-caching-fisherman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304869,"owners_count":20593626,"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":[],"created_at":"2024-12-02T05:18:35.307Z","updated_at":"2025-03-24T16:15:35.919Z","avatar_url":"https://github.com/maxerbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Command Caching Fisherman\n\n\u003e A command caching middleware, used to cache the result of a command.\n\u003e Copyright © 2017, Simon Sassi\n\n\u003ch1 align=\"center\"\u003e\u003cimg width=\"150\" src=\"https://cdn.rawgit.com/maxerbox/parallel-handle-fisherman/64ee8684/badge.png\" alt=\"fisherman\"\u003e\u003c/h1\u003e\n\n## Installation\n\n```terminal\nnpm install --save command-caching-fisherman\n```\n\n## Usage\n\nA sample example, it's caching the result of a command for 20 seconds.\nIf you trigger the command `test` two times in less than 20 seconds, it will display the same timestamp\n\n```javascript\nconst fisherman = require(\"fisherman-discord.js\")\nvar bot = new fisherman.Fisherman({ prefixes: ['test!'] }) // creating a new fisherman client, with the prefixe \"test!\"\nconst CommandCaching = require(\"command-caching-fisherman\")\nvar caching = new CommandCaching({ cachemanOptions: { ttl: 20 } }) //Creating a new CommandCaching with a 20s default \"Title to live\"\n//(ttl). The command result will be cached 20s if no ttl time is provided\nbot.use(caching) //appending the middleware\nvar register = bot.createRegister('test', 'test') //creating a new register named \"test\"\nconsole.log('registerCreated')\nregister.textCommand('test', null, function (req, res) { //creating a new command named \"test\", will be trigerred with test!test\n  console.log(\"Command trigerred\")\n  res.sendAndCache(\"Date: \" + Date.now()) //Send the current date. Result : \"Date: 1501522374948\"\n})\nbot.on('fisherCode', function (router, code, err) { //Handling fishercodes\n  router.response.send('fisherCode ' + code + '\\nError message: ' + err.message)\n})\nbot.init('_token_') //logging in the bot\n```\n\n## Backend with redis, mongo, etc\n\nBecause this middleware is using cacheman, you can set a custom cache engine. By default `cacheman` uses the `cacheman-memory` engine.\n\nSee [https://www.npmjs.com/package/cacheman](https://www.npmjs.com/package/cacheman)\n\n## Api\n\n### req.sendAndCache(text[, messageOptions = {}, ttl])\n\n`text`: The message to send\n\n`messageOptions`: discord.js message options, available [here](https://discord.js.org/#/docs/main/stable/typedef/MessageOptions)\n\n`ttl`: Time To Live in seconds\n\n### Disabling the cache feature on a command (it will not check if command result is in cache)\n\nJust set the option `disableCaching` to `true` in the `locales` property of the command\n\n```javascript\nregister.textCommand('test', {locales: {disableCaching : true}}, function (req, res) {\n[...]\n```\n\n### Constructor options\n\n| Name | Default value | Description |\n| ---- | ------ | ----- |\n| cacheName | `\"commandCache\"` | The key prefixe used by cacheman to store the command results |\n| cachemanOptions | `{}` | The cacheman's options, available [here](https://www.npmjs.com/package/cacheman)\n| keyGenerator | `function (req) { return req.message.author.id + req.command.name }` | Used to generate the cache key |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxerbox%2Fcommand-caching-fisherman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxerbox%2Fcommand-caching-fisherman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxerbox%2Fcommand-caching-fisherman/lists"}