{"id":19905569,"url":"https://github.com/ekristen/node-github-cache","last_synced_at":"2025-09-26T05:32:01.251Z","repository":{"id":24614289,"uuid":"28023119","full_name":"ekristen/node-github-cache","owner":"ekristen","description":"Provides transparent caching for node-github api calls","archived":false,"fork":false,"pushed_at":"2020-05-25T04:07:51.000Z","size":858,"stargazers_count":14,"open_issues_count":6,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-13T07:47:19.029Z","etag":null,"topics":["cache","github","nodejs"],"latest_commit_sha":null,"homepage":null,"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/ekristen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-15T06:07:02.000Z","updated_at":"2022-03-11T19:18:43.000Z","dependencies_parsed_at":"2022-08-06T03:00:34.699Z","dependency_job_id":null,"html_url":"https://github.com/ekristen/node-github-cache","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekristen%2Fnode-github-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekristen%2Fnode-github-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekristen%2Fnode-github-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekristen%2Fnode-github-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekristen","download_url":"https://codeload.github.com/ekristen/node-github-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234188175,"owners_count":18793194,"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":["cache","github","nodejs"],"created_at":"2024-11-12T20:33:54.735Z","updated_at":"2025-09-26T05:31:55.981Z","avatar_url":"https://github.com/ekristen.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/ekristen/node-github-cache.svg)](https://travis-ci.org/ekristen/node-github-cache) [![Dependency Status](https://david-dm.org/ekristen/node-github-cache.svg)](https://david-dm.org/ekristen/node-github-cache) [![devDependency Status](https://david-dm.org/ekristen/node-github-cache/dev-status.svg)](https://david-dm.org/ekristen/node-github-cache#info=devDependencies) [![npm version](https://badge.fury.io/js/github-cache.svg)](http://badge.fury.io/js/github-cache) [![Greenkeeper badge](https://badges.greenkeeper.io/ekristen/node-github-cache.svg)](https://greenkeeper.io/)\n\n# Caching Layer for Node-GitHub\n\nThis is a Node.JS module that transparently adds caching for the [node-github](https://github.com/mikedeboer/node-github) project. This library makes use of [node-libkv](https://github.com/ekristen/node-libkv) for providing a consistent API layer for multiple different key/value storage backends.\n\nBy default if no `cachedb` is setup, a local leveldb instance will be created. \n\n[![NPM](https://nodei.co/npm/github-cache.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/github-cache/)\n\n## Changelog\n\n### 2.2.0\n\nThank you to @jdanyow, he put together the PR and commits to make this possible.\n\n* You can use callbacks or promises just like you can with node-github.\n* You can use just about ANY version of node-github with this now too, however you must use 0.13.1 if you are going to use 0.13.x branch, as 0.13.1 has a fix to expose 304 http error codes.\n\n### 2.0.0\n\n* `github` is no longer a dependency of `github-cache`, this should allow this library to work with whatever version of `github` you need to work with now.\n* You must instantiate an instance of `node-github` and then pass it into the constructor for the caching library.\n* `github-cache` now uses `libkv` to provide access to key/value backends, the default still being leveldb\n* The default separator is now `/`, this allows more key/value backends to be used by default\n\n\n## Installation\n\nInstall with Node.JS package manager\n\n```\n$ npm install github-cache\n```\n\n## Documentation\n\nYou use this class just like you would use [node-github](https://github.com/mikedeboer/node-github). \n\nIf you want to not use the cache at any time, add `cache: false` to your API call.\n\n## Settings\n\n1. `cachedb` - this is a value passed to the creation of the API object `Default: level:///./github-cachedb`\n  - this can be a string in the format of a URI that is understood by libkv\n  - this can be an object with a `uri` property as well as other options understood by libkv\n  - this can be a custom cache object (explained below)\n2. `cache` - this is a value that can be passed to any API function with a boolean value to disable or enable the cache. `Default: true`\n3. `validateCache` - `Default: true` - Check cached etag using `If-None-Match` with GitHub API before using the cached data. Ensures you have the latest data at all times. Setting to `false` allows you to use cached data without making the API call, results in quicker lookups. Especially useful if you are making dozens of API calls or more.\n4. `prefix` - `Default: ''` - this will prefix all keys in the key/value storage system\n5. `separator` - `Default: /` - this will separate the various layers of key\n\n## Example\n\n### Using libkv + redis \n\nRedis must be running on the localhost in this example.\n\n```javascript\nvar GitHubApi = require('github')\nvar GitHubCache = require('github-cache')\n\nvar github_api = new GitHubApi({\n  version: '3.0.0',\n  validateCache: true\n})\n\nvar github = new GitHubCache(github_api, {\n  cachedb: 'redis://'\n})\n\ngithub.user.getFollowingFromUser({\n  user: 'ekristen',\n  cache: false\n}, function(err, res) {\n  console.log(JSON.stringify(res))\n})\n\ngithub.orgs.getTeams({\n  org: 'private',\n  validateCache: false\n}, function (err, teams) {\n  console.log(teams)\n})\n\n```\n\n### Using consul library directly\n\n```javascript\nvar GitHubCache = require('github-cache')\n\nvar consul = require('consul')({\n  host: '127.0.0.1'\n})\n\n// Need to make the set function available as `put` for the cache library to work.\nconsul.kv.put = consul.kv.set\n\n// You will want to use a prefix and a `/` separator so that they keys get separated out better in consul.\nvar github_api = new GitHubAPI({\n  version: '3.0.0'\n})\n\nvar github = new GitHubCache({\n  cachedb: consul.kv,\n  prefix: 'github-cache',\n  separator: '/'\n})\n\ngithub.authenticate({\n  type: 'oauth',\n  token: process.env.GHTOKEN\n})\n\ngithub.user.getFollowingFromUser({\n  user: 'ekristen',\n}, function (err, data) {\n  console.log(data)\n})\n\n```\n\n## Custom CacheDB Instance\n\nYou may pass in your own custom cachedb instance to `github-cache` to be valid and to work you will need the following function available: `put`, `get`, `del`, and `batch`. For more information see https://github.com/Level/levelup#api\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekristen%2Fnode-github-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekristen%2Fnode-github-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekristen%2Fnode-github-cache/lists"}