{"id":21558155,"url":"https://github.com/koopjs/koop-cache-memory","last_synced_at":"2025-04-10T10:41:38.906Z","repository":{"id":37994572,"uuid":"81742883","full_name":"koopjs/koop-cache-memory","owner":"koopjs","description":"Deprecated","archived":false,"fork":false,"pushed_at":"2023-07-11T19:11:40.000Z","size":117,"stargazers_count":0,"open_issues_count":2,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-04-09T14:59:02.930Z","etag":null,"topics":["deprecated"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koopjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2017-02-12T17:19:42.000Z","updated_at":"2022-12-10T01:56:07.000Z","dependencies_parsed_at":"2024-11-24T10:00:44.723Z","dependency_job_id":null,"html_url":"https://github.com/koopjs/koop-cache-memory","commit_stats":{"total_commits":61,"total_committers":7,"mean_commits":8.714285714285714,"dds":0.639344262295082,"last_synced_commit":"3564b2aec853981b62e469b3c1d918aa999e2470"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koopjs%2Fkoop-cache-memory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koopjs%2Fkoop-cache-memory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koopjs%2Fkoop-cache-memory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koopjs%2Fkoop-cache-memory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koopjs","download_url":"https://codeload.github.com/koopjs/koop-cache-memory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199346,"owners_count":21063656,"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":["deprecated"],"created_at":"2024-11-24T08:14:07.325Z","updated_at":"2025-04-10T10:41:38.881Z","avatar_url":"https://github.com/koopjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Koop Memory Cache\n\n## DEPRECATED - now migrated to a package in the [Koop monorepo](https://github.com/koopjs/koop/).\n\n[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)\n[![Build Status](https://travis-ci.org/koopjs/koop-cache-memory.svg?branch=master)](https://travis-ci.org/koopjs/koop-cache-memory) [![Greenkeeper badge](https://badges.greenkeeper.io/koopjs/koop-cache-memory.svg)](https://greenkeeper.io/)\n\n## Usage\n\nThis is the default cache for [Koop](https://github.com/koopjs/koop) so you won't need to instantiate it yourself. If you really wanted to, it would look like this:\n\n```js\nconst Koop = require('koop')\nconst koop = new Koop()\nconst cache = require('@koopjs/cache-memory')\nkoop.register(cache)\n```\n\n## Cache API\nThe cache is a JavaScript object that lives in-memory. It is used to store geojson features.\n\n### `insert`\nInsert geojson into the cache\n\nNote: A metadata entry will be created automatically. It can be populated from an object on the inserted geojson.\n\n```js\nconst geojson = {\n  type: 'FeatureCollection',\n  features: [],\n  metadata: { // Metadata is an arbitrary object that will be stored in the catalog under the same key as the geojson\n    name: 'Example GeoJSON',\n    description: 'This is geojson that will be stored in the cache'\n  }\n}\n\nconst options = {\n  ttl: 1000 // The TTL option is measured in seconds, it will be used to set the `expires` field in the catalog entry\n}\n\ncache.insert('key', geojson, options, err =\u003e {\n  // This function will call back with an error if there is already data in the cache using the same key\n})\n```\n\n### `append`\nAdd features to an existing geojson feature collection in the cache\nNote:\n\n```js\nconst geojson = {\n  type: 'FeatureCollection',\n  features: []\n}\ncache.append('key', geojson, err =\u003e {\n  // This function will call back with an error if the cache key does not exist\n})\n```\n\n### `update`\nUpdate a cached feature collection with new features.\nThis will completely replace the features that are in the cache, but the metadata doc will remain in the catalog.\n\n```js\nconst geojson = {\n  type: 'FeatureCollection',\n  features: []\n}\n\nconst options = {\n  ttl: 1000\n}\ncache.update('key', geojson, options, err =\u003e {\n  // This function will call back with an error if the cache key does not exist\n})\n```\n\n### `upsert`\nUpdate a cached feature collection with new features or insert if the features are not there.\n\n```js\nconst geojson = {\n  type: 'FeatureCollection',\n  features: []\n}\n\nconst options = {\n  ttl: 1000\n}\n\ncache.upsert('key', geojson, options, err =\u003e {\n  // This function will call back with an error if the cache key does not exist\n})\n```\n\n### `retrieve`\nRetrieve a cached feature collection\n\n```js\nconst options = {} // For now there are no options on retrieve. This is meant for compatibility with the general cache API\ncache.retrieve('key', options, (err, geojson) =\u003e {\n  /* This function will call back with an error if there is no geojson in the cache\n  The geojson returned will contain the metadata document from the catalog\n  {\n    type: 'FeatureCollection',\n    features: [],\n    metadata: {}\n  }\n  */\n})\n```\n\n### `delete`\nRemove a feature collection from the cache\n\n```js\ncache.delete('key', err =\u003e {\n  // This function will call back with an error if there was nothing to delete\n})\n```\n\n### `createStream`\nCreate a stream of features from the cache\n\n```js\ncache.createStream('key', options)\n.pipe(/* do something with the stream of geojson features emitted one at a time */)\n```\n\n## Catalog API\nThe catalog stores metadata about items that are in the cache.\n\n### `catalog.insert`\nAdd an arbitrary metadata document to the cache.\nNote: This is called automatically by `insert`\n\n```js\nconst metadata = {\n  name: 'Standalone metadata',\n  status: 'Processing',\n  description: 'Metadata that is not attached to any other data in the cache'\n}\n\ncache.catalog.insert('key', metadata, err =\u003e {\n  // this function will call back with an error if there is already a metadata document using the same key\n})\n```\n\n### `catalog.update`\nUpdate a metadata entry\n\n```js\nconst original = {\n  name: 'Doc',\n  status: 'Processing'\n}\ncache.catalog.insert('key', original)\n\nconst update = {\n  status: 'Cached'\n}\n\ncache.catalog.update('key', update, err =\u003e {\n  // this function will call back with an error if there is no metadata in the catalog using that key\n})\n\ncache.catalog.retrieve('key', (err, metadata) =\u003e {\n  /*\n    Updates are merged into the existing metadata document\n    Return value will be:\n    {\n      name: 'Doc',\n      status: 'Cached'\n    }\n  */\n})\n```\n\n### `catalog.retrieve`\nRetrieve a metadata entry from the catalog\n\n```js\ncache.catalog.retrieve('key', (err, metadata) =\u003e {\n  // This function will call back with an error if there is no metadata stored under the given key\n  // Or else it will call back with the stored metadata doc\n})\n```\n\n### `catalog.delete`\nRemove a catalog entry from the catalog\nNote: This cannot be called if data is in the cache under the same key\n\n```js\ncache.catalog.delete('key', err =\u003e {\n  // This function will call back with an error if there is nothing to delete or if there is still data in the cache using the same key\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoopjs%2Fkoop-cache-memory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoopjs%2Fkoop-cache-memory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoopjs%2Fkoop-cache-memory/lists"}