{"id":20129318,"url":"https://github.com/aicore/libcache","last_synced_at":"2025-03-02T21:27:10.332Z","repository":{"id":36961893,"uuid":"503267150","full_name":"aicore/libcache","owner":"aicore","description":"caching library for memcached","archived":false,"fork":false,"pushed_at":"2025-02-21T23:35:14.000Z","size":345,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-22T00:26:00.607Z","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":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aicore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2022-06-14T08:11:04.000Z","updated_at":"2024-03-31T18:31:25.000Z","dependencies_parsed_at":"2023-01-17T08:47:29.149Z","dependency_job_id":"e194e1a6-e79a-4706-a65b-8c876b0dd545","html_url":"https://github.com/aicore/libcache","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"aicore/template-nodejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Flibcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Flibcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Flibcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aicore%2Flibcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aicore","download_url":"https://codeload.github.com/aicore/libcache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241573069,"owners_count":19984413,"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-11-13T20:33:33.579Z","updated_at":"2025-03-02T21:27:10.307Z","avatar_url":"https://github.com/aicore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libcache\n\nThis library will be used for caching data in our internal services.\n## How to use Library\nWe pass all configurations using environment variables. Following are environment variables available.\n\nPlease set following environment variables before using this library in production\n\n    MEMCACHIER_SERVERS - used to determine which servers to connect to. Should be a comma separated list of [hostname:port].\n    MEMCACHIER_USERNAME - if present with MEMCACHIER_PASSWORD, MemJS will try to authenticated to the server using SASL.\n    MEMCACHIER_PASSWORD - if present with MEMCACHIER_USERNAME, MemJS will try to authenticated to the server using SASL.\n    MEMCACHE_USERNAME - used if MEMCACHIER_USERNAME is not present\n    MEMCACHE_PASSWORD - used if MEMCACHIER_PASSWORD is not present\n```js\n// sample code on how to use library\nimport  {putToCache, getValueFromCache, deleteKeyFromCache, closeCache} from '@aicore/libcache';\nconst key = 'hello';\nconst value = {\n  'name' : 'ram',\n  'age' : 100  \n};\n\nconst ttl = 100; // in seconds\ntry {\n    await putToCache(key, value, ttl);\n}catch (e){\n    console.error(e);\n}\n\ntry {\n    await getValueFromCache(key);\n} catch (e){\n    console.error(e);\n}\ntry {\n    await deleteKeyFromCache(key);\n} catch (e){\n    console.log(e);\n}\n// close cache client\ncloseCache();\n```\n\n\n\n## Code Guardian\n\n[![\u003capp\u003e build verification](https://github.com/aicore/libcache/actions/workflows/build_verify.yml/badge.svg)](https://github.com/aicore/libcache/actions/workflows/build_verify.yml)\n\n\u003ca href=\"https://sonarcloud.io/summary/new_code?id=aicore_libcache\"\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=alert_status\" alt=\"Sonar code quality check\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=security_rating\" alt=\"Security rating\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=vulnerabilities\" alt=\"vulnerabilities\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=coverage\" alt=\"Code Coverage\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=bugs\" alt=\"Code Bugs\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=reliability_rating\" alt=\"Reliability Rating\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=sqale_rating\" alt=\"Maintainability Rating\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=ncloc\" alt=\"Lines of Code\" /\u003e\n  \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=aicore_libcache\u0026metric=sqale_index\" alt=\"Technical debt\" /\u003e\n\u003c/a\u003e\n\n# Commands available\n\n## Building\nWe run integration tests on `Ubuntu`  so we recommend Ubuntu for building the packages.\n\n```shell\n\u003e npm install   // do this only once.\n\u003e npm run build\n```\n\n## Linting\n\nTo lint the files in the project, run the following command:\n\n```shell\n\u003e npm run lint\n```\n\nTo Automatically fix lint errors:\n\n```shell\n\u003e npm run lint:fix\n```\n\n## Testing\n\nTo run all tests:\n\n```shell\n\u003e npm run test\n  Hello world Tests\n    ✔ should return Hello World\n    #indexOf()\n      ✔ should return -1 when the value is not present\n```\n\nAdditionally, to run unit/integration tests only, use the commands:\n\n```shell\n\u003e npm run test:unit\n\u003e npm run test:integ\n```\n\n## Coverage Reports\n\nTo run all tests with coverage:\n\n```shell\n\u003e npm run cover\n  Hello world Tests\n    ✔ should return Hello World\n    #indexOf()\n      ✔ should return -1 when the value is not present\n\n\n  2 passing (6ms)\n\n----------|---------|----------|---------|---------|-------------------\nFile      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s \n----------|---------|----------|---------|---------|-------------------\nAll files |     100 |      100 |     100 |     100 |                   \n index.js |     100 |      100 |     100 |     100 |                   \n----------|---------|----------|---------|---------|-------------------\n\n=============================== Coverage summary ===============================\nStatements   : 100% ( 5/5 )\nBranches     : 100% ( 2/2 )\nFunctions    : 100% ( 1/1 )\nLines        : 100% ( 5/5 )\n================================================================================\nDetailed unit test coverage report: file:///template-nodejs/coverage-unit/index.html\nDetailed integration test coverage report: file:///template-nodejs/coverage-integration/index.html\n```\n\nAfter running coverage, detailed reports can be found in the coverage folder listed in the output of coverage command.\nOpen the file in browser to view detailed reports.\n\nTo run unit/integration tests only with coverage\n\n```shell\n\u003e npm run cover:unit\n\u003e npm run cover:integ\n```\n\nSample coverage report:\n![image](https://user-images.githubusercontent.com/5336369/148687351-6d6c12a2-a232-433d-ab62-2cf5d39c96bd.png)\n\n### Unit and Integration coverage configs\n\nUnit and integration test coverage settings can be updated by configs `.nycrc.unit.json` and `.nycrc.integration.json`.\n\nSee https://github.com/istanbuljs/nyc for config options.\n\n# Publishing packages to NPM\n\nTo publish a package to npm, push contents to `npm` branch in\nthis repository.\n\n## Publishing `@aicore/package*`\n\nIf you are looking to publish to package owned by core.ai, you will need access to the GitHub Organization\nsecret `NPM_TOKEN`.\n\nFor repos managed by [aicore](https://github.com/aicore) org in GitHub, Please contact your Admin to get access to\ncore.ai's NPM tokens.\n\n## Publishing to your own npm account\n\nAlternatively, if you want to publish the package to your own npm account, please follow these docs:\n\n1. Create an automation access token by following this [link](https://docs.npmjs.com/creating-and-viewing-access-tokens)\n   .\n2. Add NPM_TOKEN to your repository secret by following\n   this [link](https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow)\n\nTo edit the publishing workflow, please see file: `.github/workflows/npm-publish.yml`\n\n# Dependency updates\n\nWe use Rennovate for dependency updates: https://blog.logrocket.com/renovate-dependency-updates-on-steroids/\n\n* By default, dep updates happen on sunday every week.\n* The status of dependency updates can be viewed here if you have this repo permissions in\n  github: https://app.renovatebot.com/dashboard#github/aicore/template-nodejs\n* To edit rennovate options, edit the rennovate.json file in root,\n  see https://docs.renovatebot.com/configuration-options/\n  Refer\n\n# Code Guardian\n\nSeveral automated workflows that check code integrity are integrated into this template.\nThese include:\n\n1. GitHub actions that runs build/test/coverage flows when a contributor raises a pull request\n2. [Sonar cloud](https://sonarcloud.io/) integration using `.sonarcloud.properties`\n    1. In sonar cloud, enable Automatic analysis from `Administration\n       Analysis Method` for the first\n       time ![image](https://user-images.githubusercontent.com/5336369/148695840-65585d04-5e59-450b-8794-54ca3c62b9fe.png)\n\n## IDE setup\n\nSonarLint is currently available as a free plugin for jetbrains, eclipse, vscode and visual studio IDEs.\nUse sonarLint plugin for webstorm or any of the available\nIDEs from this link before raising a pull request: https://www.sonarlint.org/ .\n\nSonarLint static code analysis checker is not yet available as a Brackets\nextension.\n\n## Internals\n\n### Testing framework: Mocha , assertion style: chai\n\nSee https://mochajs.org/#getting-started on how to write tests\nUse chai for BDD style assertions (expect, should etc..). See move here: https://www.chaijs.com/guide/styles/#expect\n\n### Mocks and spies: sinon\n\nif you want to mock/spy on fn() for unit tests, use sinon. refer docs: https://sinonjs.org/\n\n### Note on coverage suite used here:\n\nwe use c8 for coverage https://github.com/bcoe/c8. Its reporting is based on nyc, so detailed docs can be found\nhere: https://github.com/istanbuljs/nyc ; We didn't use nyc as it do not yet have ES module support\nsee: https://github.com/digitalbazaar/bedrock-test/issues/16 . c8 is drop replacement for nyc coverage reporting tool\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faicore%2Flibcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faicore%2Flibcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faicore%2Flibcache/lists"}