{"id":19020241,"url":"https://github.com/trailsjs/trailpack-cache","last_synced_at":"2025-04-23T05:26:27.868Z","repository":{"id":57378809,"uuid":"63690981","full_name":"trailsjs/trailpack-cache","owner":"trailsjs","description":":package:  Cache Trailpack","archived":false,"fork":false,"pushed_at":"2017-06-24T14:53:50.000Z","size":29,"stargazers_count":3,"open_issues_count":2,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-17T20:40:01.636Z","etag":null,"topics":["trailpack","trails"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/trailsjs.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":"2016-07-19T12:10:10.000Z","updated_at":"2024-03-07T07:33:46.000Z","dependencies_parsed_at":"2022-09-02T20:22:21.116Z","dependency_job_id":null,"html_url":"https://github.com/trailsjs/trailpack-cache","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trailsjs%2Ftrailpack-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trailsjs","download_url":"https://codeload.github.com/trailsjs/trailpack-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250375658,"owners_count":21420171,"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":["trailpack","trails"],"created_at":"2024-11-08T20:16:15.019Z","updated_at":"2025-04-23T05:26:27.826Z","avatar_url":"https://github.com/trailsjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trailpack-cache\n\n[![Gitter][gitter-image]][gitter-url]\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][npm-download]][npm-url]\n[![Build status][ci-image]][ci-url]\n[![Dependency Status][daviddm-image]][daviddm-url]\n[![Code Climate][codeclimate-image]][codeclimate-url]\n\n:package: Cache Trailpack\n\n\n## Install\n### With yeoman :\n\n```sh\nnpm install -g yo generator-trails\nyo trails:trailpack trailpack-cache\n```\n### With npm (you will have to create config file manually) :\n```sh\n$ npm install --save trailpack-cache\n```\n\n## Configure\n\n```js\n// config/main.js\nmodule.exports = {\n  packs: [\n    // ... other trailpacks\n    require('trailpack-cache')\n  ]\n}\n```\n\n## Configuration\n\n```\nconst mongoStore = require('cache-manager-mongodb')\nconst redisStore = require('cache-manager-redis')\n// config/caches.js\nmodule.exports = {\n  stores: [\n  // Example for redis Store\n  {\n    name: 'my-redis-store',\n    store: redisStore,\n    host: 'localhost',\n    auth_pass: ''\n    db: 0,\n    ttl: 600 // Default TTL\n  },\n  // Example for memory store\n  {\n    name: 'memory-store',\n    store: 'memory',\n    max: 100,\n    ttl: 60\n  },\n  // Example for mongo store\n  {\n    name: 'mongo-store',\n    store: mongoStore,\n    options: {\n      host: 'localhost',\n      port: '27017',\n      username: 'username',\n      password: 'password',\n      database: 'mymondodb',\n      collection: 'cacheManager',\n      compression: false,\n      poolSize: 5,\n      auto_reconnect: true\n      ttl: 60\n    }\n  }],\n\n  defaults: ['memory-store']\n}\n```\n\nFor more information about store (type and configuration) please see the cache-manager documentation.\n\n## Usage\n\n```JavaScript\n  const myDefaultCache = this.app.services.CacheService.getStore() // Return the first store into defaults config\n  myDefaultCache.set('mystoreddata', 'testValue', {ttl: 10}).then(result =\u003e {\n  return myDefaultCache.get('mystoreddata').then(result =\u003e {\n        console.log(result)\n        // \u003e\u003e 'testValue'\n        return myDefaultCache.del('mystoreddata')\n    })\n  })\n\n```\n\nYou can retrieve a specific store by name like this: \n`const myMongoCache = this.app.services.CacheService.getStore('mongo-store')`\n\nYou can retrieve a multi caching store like this (without parameters to get multi caching with defaults stores): \n`const myMongoCache = this.app.services.CacheService.getMultiCachingStore(['memory-store', 'mongo-store'])`\n\n## Contributing\nWe love contributions! Please check out our [Contributor's Guide](https://github.com/trailsjs/trails/blob/master/.github/CONTRIBUTING.md) for more\ninformation on how our projects are organized and how to get started.\n\n## License\n[MIT](https://github.com/trailsjs/trailpack-hapi/blob/master/LICENSE)\n\n\u003cimg src=\"http://i.imgur.com/dCjNisP.png\"\u003e\n\n[npm-image]: https://img.shields.io/npm/v/trailpack-cache.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/trailpack-cache\n[npm-download]: https://img.shields.io/npm/dt/trailpack-cache.svg\n[ci-image]: https://img.shields.io/travis/trailsjs/trailpack-cache/master.svg?style=flat-square\n[ci-url]: https://travis-ci.org/trailsjs/trailpack-cache\n[daviddm-image]: http://img.shields.io/david/trailsjs/trailpack-cache.svg?style=flat-square\n[daviddm-url]: https://david-dm.org/trailsjs/trailpack-cache\n[codeclimate-image]: https://img.shields.io/codeclimate/github/trailsjs/trailpack-cache.svg?style=flat-square\n[codeclimate-url]: https://codeclimate.com/github/trailsjs/trailpack-cache\n[gitter-image]: http://img.shields.io/badge/+%20GITTER-JOIN%20CHAT%20%E2%86%92-1DCE73.svg?style=flat-square\n[gitter-url]: https://gitter.im/trailsjs/trails\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrailsjs%2Ftrailpack-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrailsjs%2Ftrailpack-cache/lists"}