{"id":14991064,"url":"https://github.com/fusioncharts/redis-contentful","last_synced_at":"2025-04-12T03:25:48.432Z","repository":{"id":52497492,"uuid":"125598528","full_name":"fusioncharts/redis-contentful","owner":"fusioncharts","description":"A tiny library to map Contentful ☁️ space into Redis ⚡️","archived":false,"fork":false,"pushed_at":"2022-12-06T14:34:00.000Z","size":198,"stargazers_count":17,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T23:05:09.875Z","etag":null,"topics":["cache","cms","contentful","redis"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/redis-contentful","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/fusioncharts.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":"2018-03-17T05:03:09.000Z","updated_at":"2024-03-20T10:09:00.000Z","dependencies_parsed_at":"2023-01-23T08:15:33.755Z","dependency_job_id":null,"html_url":"https://github.com/fusioncharts/redis-contentful","commit_stats":null,"previous_names":["shreyas-a/cf-redis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusioncharts%2Fredis-contentful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusioncharts%2Fredis-contentful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusioncharts%2Fredis-contentful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fusioncharts%2Fredis-contentful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fusioncharts","download_url":"https://codeload.github.com/fusioncharts/redis-contentful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248511291,"owners_count":21116384,"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","cms","contentful","redis"],"created_at":"2024-09-24T14:21:24.290Z","updated_at":"2025-04-12T03:25:48.408Z","avatar_url":"https://github.com/fusioncharts.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redis Contentful [![npm](https://img.shields.io/npm/v/redis-contentful.svg)](https://www.npmjs.com/package/redis-contentful) [![license](https://img.shields.io/github/license/fusioncharts/redis-contentful.svg)](https://github.com/fusioncharts/redis-contentful/blob/master/LICENSE)\n\nA tiny library to map Contentful ☁️ space into Redis ⚡️\n\n## Why should I care?\n\nSay your marketing team loves to update content without you being involved? Great! That is why you should use Contentful CMS. But wait, there is a catch. Contentful API sometimes takes `~800ms`. And this is really a hit when you're having fancy SSR implemented to boost the performance of your Node JS app. As the creator of Gmail, Paul Buchheit had said \"Every interaction should be faster than `100ms`. Why? Because `100ms` is the threshold where interactions feel instantaneous\".\n\nThis is where redis will help you crunch the rendering speed. It's really, really fast! A few `ms` is all it needs to get your data. By few, I mean less than `100ms` 🚀\n\n`redis-contentful` maps your Contentful space's content types and their published records into your Redis server. It also maintains the schema of your Contentful space. All content types are stored in Redis as hashes. Under a particular hash, the record is stored as a key value pair with id being the record's key.\n\nYou can `sync` the data manually by calling the sync method on `redis-contentful` instance manually or you can add a webhook in Contentful by exposing an endpoint on your server which will internally call `sync`. In this way, you always have the latest content from Contentful right in your Redis.\nSo let's get started!\n\n## Installation\n\n```sh\nnpm install redis-contentful --save\n```\n\n## Usage\n\nCreate an instance of `redis-contentful` by passing contentful space ID \u0026 access token.\n\n```js\nimport RedisContentful from 'redis-contentful';\n\nconst client = new RedisContentful({\n  redis: {\n    database: 0, // Optional param, default - 0\n    host: '', // Optional param, default - 127.0.0.1\n    port: '', // Optional param, default - 6379\n  },\n  contentful: {\n    space: '',\n    accessToken: '',\n    locale: '', // Optional param, default - en-US\n    identifier: '', // Identifier for searching custom keys,\n    environment: '', // contentful environment, default is master\n  },\n});\n```\n\n## API\n\n### sync\n\nSyncs the latest space content from Contentful and dumps it in your Redis server 🎉\n\n```js\nawait client.sync();\n```\n\nSend an optional boolean param to `sync` if you want to reset your redis cache ♻️\n\n```js\nawait client.sync(true);\n```\n\n### get - _directly from Redis 🚀_\n\nGets all data\n\n```js\nawait client.get();\n```\n\nPass specific content type. It's an optional parameter.\n\n```js\nawait client.get('about');\n```\n\nPass an array specifying the required content types\n\n```js\nawait client.get(['about', 'title']);\n```\n\nPass an object to narrow down search\n\n```js\nawait client.get({\n  // Content type, it can also be an array\n  type: '',\n\n  // This will search identifier key for specified value\n  search: '',\n});\n```\n\nYou'll get an object with your content type ID's as keys and their values as array of content objects.\nIf you specify a specific key, only that key will be returned in the final object.\n\n```js\n{\n    \"\u003ca-key\u003e\": [{}, {}, {}],\n    \"\u003cyet-another-key\u003e\": [{}, {}]\n}\n```\n\n### Custom keys in Redis\n\nSet, get \u0026 delete your custom key - value pairs in Redis\n\n```js\nawait client.setCustom('avengers', '🤯');\n/* can set expire time in seconds. Third parameter is optional */\nawait client.setCustom('Hulk', \"I'm Hulk!\", 60);\nawait client.getCustom('avengers'); // 🤯\nawait client.deleteCustom('avengers');\n```\n\n### Changing Redis DB\n\n```js\n// Sets DB to specified value, default is 0\nawait client.setDB();\n```\n\n### close\n\nCloses the connection to redis client.\n\n```js\nawait client.close();\n```\n\n## Redis Store\n\n\u003e In Redis, the keys (entries) will be prefixed with their respective content type 🤓\n\n## License\n\nMIT ❤\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusioncharts%2Fredis-contentful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusioncharts%2Fredis-contentful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusioncharts%2Fredis-contentful/lists"}