Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
dda83e35c0 | |||
8bf1af08d3 | |||
69b2aa7fb8 | |||
75140e9d70 | |||
e45c662658 | |||
d9b0ebb5ed | |||
f5075abafb | |||
e131b8c9ff | |||
244d229fa3 | |||
96080c5de0 | |||
a981c63f9b | |||
cd5e2f03f4 | |||
eb5c1f40ee | |||
ed1d66ee2a | |||
45122024fc | |||
fcaed1a3a0 | |||
0ce5eba798 | |||
9d6111a77f | |||
ac11045812 | |||
2266ee0c73 | |||
e4f0a60644 | |||
946e1cb7d3 | |||
6e5d17a793 | |||
3f7a3c2786 | |||
925921a9fe |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
140
.gitlab-ci.yml
140
.gitlab-ci.yml
@ -1,140 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
75
changelog.md
Normal file
75
changelog.md
Normal file
@ -0,0 +1,75 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-11-26 - 3.1.1 - fix(core)
|
||||
Fix S3 cache manager methods for better path encoding consistency
|
||||
|
||||
- Corrected path parameter usage in S3 manager methods to ensure encoding and consistency.
|
||||
- Updated package.json Git dependencies for scoped packages.
|
||||
|
||||
## 2024-11-24 - 3.1.0 - feat(core)
|
||||
Enhanced caching solution with optional configurations and improved documentation.
|
||||
|
||||
- Improved package description and keywords for better discoverability.
|
||||
- Updated dependencies to latest versions.
|
||||
- Added strict type checking in TypeScript configurations.
|
||||
- Enhanced README with detailed usage instructions and examples.
|
||||
|
||||
## 2024-05-29 to 2024-02-14 - 3.0.8
|
||||
Minor configuration updates and documentation changes.
|
||||
|
||||
- Updated project description.
|
||||
- Modified tsconfig setup.
|
||||
- Adjustments to npmextra.json regarding githost.
|
||||
|
||||
## 2024-02-14 - 3.0.7
|
||||
Core enhancements and bug fixes.
|
||||
|
||||
- Fixed updates in the core module to improve stability.
|
||||
|
||||
## 2024-02-14 - 3.0.6
|
||||
Core maintenance and updates.
|
||||
|
||||
- Implemented minor fixes in the core module.
|
||||
|
||||
## 2023-07-21 - 3.0.5
|
||||
Addressed core module adjustments.
|
||||
|
||||
- Patched core module to rectify issues.
|
||||
|
||||
## 2023-07-20 - 3.0.4
|
||||
Further improvements to core functionality.
|
||||
|
||||
- Additional fixes applied to the core component.
|
||||
|
||||
## 2023-07-11 to 2023-07-10 - 3.0.3
|
||||
Organizational and structural changes.
|
||||
|
||||
- Transitioned to a new organizational scheme.
|
||||
|
||||
## 2023-01-09 - 3.0.2
|
||||
Core module corrections.
|
||||
|
||||
- Resolved various issues within the core module.
|
||||
|
||||
## 2022-06-09 - 3.0.1
|
||||
Continuous enhancements in core functionality.
|
||||
|
||||
- Continued bug fixes for core module efficiency.
|
||||
|
||||
## 2022-04-04 to 2022-04-02 - 3.0.0
|
||||
Major release with significant updates.
|
||||
|
||||
## 2022-03-22 - 2.0.0
|
||||
Significant breaking changes in core tech stack.
|
||||
|
||||
- BREAKING CHANGE: Transitioned core module to ECMAScript Modules (ESM).
|
||||
|
||||
## 2021-05-10 - 1.0.9
|
||||
Caching improvements and optimization.
|
||||
|
||||
- Enhanced caching by properly respecting TTL across all cache levels.
|
||||
|
||||
## 2020-02-15 to 2020-02-05 - 1.0.6 to 1.0.1
|
||||
Initial series of core module fixes and updates.
|
||||
|
||||
- Persistent efforts to stabilize and improve core functionalities.
|
@ -2,17 +2,34 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "levelcache",
|
||||
"description": "a cache that uses memory/disk/s3 as backup",
|
||||
"npmPackagename": "@pushrocks/levelcache",
|
||||
"description": "A versatile caching solution offering multi-level storage utilizing memory, disk, and Amazon S3 for efficient data management and backup.",
|
||||
"npmPackagename": "@push.rocks/levelcache",
|
||||
"license": "MIT",
|
||||
"projectDomain": "push.rocks"
|
||||
"projectDomain": "push.rocks",
|
||||
"keywords": [
|
||||
"caching",
|
||||
"data storage",
|
||||
"memory cache",
|
||||
"disk cache",
|
||||
"S3 storage",
|
||||
"data backup",
|
||||
"multi-level caching",
|
||||
"performance",
|
||||
"persistent storage",
|
||||
"data retrieval",
|
||||
"Node.js",
|
||||
"TypeScript"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
20361
package-lock.json
generated
20361
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
65
package.json
65
package.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@pushrocks/levelcache",
|
||||
"version": "3.0.1",
|
||||
"name": "@push.rocks/levelcache",
|
||||
"version": "3.1.1",
|
||||
"private": false,
|
||||
"description": "a cache that uses memory/disk/s3 as backup",
|
||||
"description": "A versatile caching solution offering multi-level storage utilizing memory, disk, and Amazon S3 for efficient data management and backup.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@ -10,27 +10,31 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc",
|
||||
"localPublish": "gitzone commit && pnpm run build && pnpm publish && pnpm publish --access public --registry=\"https://registry.npmjs.org\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.61",
|
||||
"@gitzone/tstest": "^1.0.70",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.23"
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.77",
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.9.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^5.0.4",
|
||||
"@pushrocks/smartbucket": "^2.0.1",
|
||||
"@pushrocks/smartcache": "^1.0.13",
|
||||
"@pushrocks/smartenv": "^5.0.1",
|
||||
"@pushrocks/smartexit": "^1.0.20",
|
||||
"@pushrocks/smartfile": "^9.0.6",
|
||||
"@pushrocks/smartjson": "^4.0.6",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@pushrocks/smartpromise": "^3.1.7",
|
||||
"@pushrocks/smartstring": "^4.0.2",
|
||||
"@pushrocks/smartunique": "^3.0.3",
|
||||
"@pushrocks/taskbuffer": "^3.0.0"
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartbucket": "^3.3.3",
|
||||
"@push.rocks/smartcache": "^1.0.13",
|
||||
"@push.rocks/smartenv": "^5.0.12",
|
||||
"@push.rocks/smartexit": "^1.0.23",
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartjson": "^5.0.20",
|
||||
"@push.rocks/smartpath": "^5.0.18",
|
||||
"@push.rocks/smartpromise": "^4.0.4",
|
||||
"@push.rocks/smartstring": "^4.0.15",
|
||||
"@push.rocks/smartunique": "^3.0.9",
|
||||
"@push.rocks/taskbuffer": "^3.1.7",
|
||||
"@tsclass/tsclass": "^4.1.2"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
@ -46,5 +50,24 @@
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
],
|
||||
"keywords": [
|
||||
"caching",
|
||||
"data storage",
|
||||
"memory cache",
|
||||
"disk cache",
|
||||
"S3 storage",
|
||||
"data backup",
|
||||
"multi-level caching",
|
||||
"performance",
|
||||
"persistent storage",
|
||||
"data retrieval",
|
||||
"Node.js",
|
||||
"TypeScript"
|
||||
],
|
||||
"homepage": "https://code.foss.global/push.rocks/levelcache",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/levelcache.git"
|
||||
}
|
||||
}
|
||||
|
9689
pnpm-lock.yaml
generated
Normal file
9689
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
191
readme.md
191
readme.md
@ -1,42 +1,173 @@
|
||||
# @pushrocks/levelcache
|
||||
a cache that uses memory/disk/s3 as backup
|
||||
# @push.rocks/levelcache
|
||||
A cache that utilizes memory, disk, and S3 for data storage and backup.
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/levelcache)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/levelcache)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/levelcache)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/levelcache/)
|
||||
## Install
|
||||
To install `@push.rocks/levelcache`, you can use npm or yarn:
|
||||
|
||||
## Status for master
|
||||
```bash
|
||||
npm install @push.rocks/levelcache --save
|
||||
```
|
||||
or
|
||||
```bash
|
||||
yarn add @push.rocks/levelcache
|
||||
```
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
This installs `@push.rocks/levelcache` and adds it to your project's dependencies.
|
||||
|
||||
## Usage
|
||||
|
||||
@pushrocks/levelcache implements an efficient way to cache larger amounts of data ind a multilevel approach.
|
||||
smaller and prioritized data is safed in memory.
|
||||
`@push.rocks/levelcache` provides a comprehensive solution for multi-level caching that takes advantage of memory, disk, and Amazon S3 storage, making it a versatile tool for data caching and backup. The package is built with TypeScript, enabling strict type checks and better development experience. Below, we'll explore how to effectively employ `@push.rocks/levelcache` in your projects, discussing its features and demonstrating its usage with code examples.
|
||||
|
||||
Use TypeScript for best in class intellisense.
|
||||
### 1. Overview
|
||||
|
||||
## Contribution
|
||||
The `LevelCache` class handles all cache operations. It decides where to store data based on pre-configured thresholds corresponding to the data size and the total storage capacity allocated for each storage type (memory/disk/S3). This mechanism optimizes both speed and persistence, allowing for efficient data storage and retrieval.
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
### 2. Getting Started: Initialization
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
To use `@push.rocks/levelcache`, you'll need to import the main classes: `LevelCache` and `CacheEntry`. `LevelCache` is the primary class, while `CacheEntry` represents individual pieces of cached data.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
```typescript
|
||||
import { LevelCache, CacheEntry } from '@push.rocks/levelcache';
|
||||
```
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
#### Initialization with Optional Configurations
|
||||
|
||||
To create a cache, instantiate the `LevelCache` class with desired configurations. You can specify the limits for memory and disk storage, setup S3 configurations if needed, and more.
|
||||
|
||||
```typescript
|
||||
const myCache = new LevelCache({
|
||||
cacheId: 'myUniqueCacheId', // Unique ID for cache delineation
|
||||
maxMemoryStorageInMB: 10, // Maximum memory use in MB (default 0.5 MB)
|
||||
maxDiskStorageInMB: 100, // Maximum disk space in MB (default 10 MB)
|
||||
diskStoragePath: './myCache', // Path for storing disk cache; default is '.nogit'
|
||||
s3Config: {
|
||||
accessKeyId: 'yourAccessKeyId', // AWS S3 access key
|
||||
secretAccessKey: 'yourSecretAccessKey', // Corresponding secret key
|
||||
region: 'us-west-2' // AWS region, e.g., 'us-west-2'
|
||||
},
|
||||
s3BucketName: 'myBucketName', // Designated name for S3 bucket
|
||||
immutableCache: false, // Whether stored cache entries should remain unaltered
|
||||
persistentCache: true, // Should the cache persist upon restarts
|
||||
});
|
||||
```
|
||||
|
||||
### 3. Storing and Retrieving Data
|
||||
|
||||
`LevelCache` methods enable seamless data storage and retrieval, handling complexity under the hood.
|
||||
|
||||
#### Storing Data
|
||||
|
||||
Create a `CacheEntry` specifying the data content and time-to-live (`ttl`). Use `storeCacheEntryByKey` to add this entry to the cache.
|
||||
|
||||
```typescript
|
||||
async function storeData() {
|
||||
// Wait for cache to be ready before operations
|
||||
await myCache.ready;
|
||||
|
||||
const entryContents = Buffer.from('Caching this data');
|
||||
const myCacheEntry = new CacheEntry({
|
||||
ttl: 7200000, // Time-to-live in milliseconds (2 hours)
|
||||
contents: entryContents,
|
||||
});
|
||||
|
||||
// Storing the cache entry associated with a specific key
|
||||
await myCache.storeCacheEntryByKey('someDataKey', myCacheEntry);
|
||||
}
|
||||
```
|
||||
|
||||
#### Retrieving Data
|
||||
|
||||
Retrieve stored data using `retrieveCacheEntryByKey`. The retrieved `CacheEntry` will give access to the original data.
|
||||
|
||||
```typescript
|
||||
async function retrieveData() {
|
||||
const retrievedEntry = await myCache.retrieveCacheEntryByKey('someDataKey');
|
||||
if (retrievedEntry) {
|
||||
const data = retrievedEntry.contents.toString();
|
||||
console.log(data); // Expected output: Caching this data
|
||||
} else {
|
||||
console.log('Data not found or expired.');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Key Management: Updating and Deleting
|
||||
|
||||
#### Deleting Cache Entries
|
||||
|
||||
Remove entries with `deleteCacheEntryByKey`, enabling clean cache management.
|
||||
|
||||
```typescript
|
||||
async function deleteData() {
|
||||
// Removes an entry using its unique key identifier
|
||||
await myCache.deleteCacheEntryByKey('someDataKey');
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Cache Cleaning
|
||||
|
||||
Often, managing storage limits or removing outdated data becomes essential. The library supports these scenarios.
|
||||
|
||||
#### Automated Cleaning
|
||||
|
||||
While cache entries will naturally expire with `ttl` values, you can force-remove outdated entries.
|
||||
|
||||
```typescript
|
||||
// Clean outdated or expired entries
|
||||
await myCache.cleanOutdated();
|
||||
```
|
||||
|
||||
#### Full Cache Reset
|
||||
|
||||
Clear all entries, efficiently resetting your cache storage.
|
||||
|
||||
```typescript
|
||||
// Flush entire cache content
|
||||
await myCache.cleanAll();
|
||||
```
|
||||
|
||||
### 6. Configuring and Managing Advanced Use Cases
|
||||
|
||||
The flexible nature of `@push.rocks/levelcache` grants additional customization suited for more advanced requirements.
|
||||
|
||||
#### Custom Route Management
|
||||
|
||||
For certain demands, you might want to specify distinct data handling policies or routing logic.
|
||||
|
||||
- Adjust S3 handling, size thresholds, or immutability options dynamically.
|
||||
- Utilize internal API expansions defined within the library for fine-grained operations.
|
||||
|
||||
#### Handling Large Datasets
|
||||
|
||||
Tailor the cache levels (memory, disk, S3) to accommodate higher loads:
|
||||
|
||||
```typescript
|
||||
const largeDatasetCache = new LevelCache({
|
||||
cacheId: 'largeDatasetCache',
|
||||
// Customize limits and behavior for particular patterns
|
||||
maxMemoryStorageInMB: 1024, // 1 GB memory allocation
|
||||
maxDiskStorageInMB: 2048, // 2 GB disk space allowance
|
||||
maxS3StorageInMB: 10240, // 10 GB S3 backup buffering
|
||||
});
|
||||
```
|
||||
|
||||
With intelligent routing and management embedded, `LevelCache` ensures optimal trade-offs between speed and stability.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as levelcache from '../ts/index.js';
|
||||
import { CacheEntry } from '../ts/index.js';
|
||||
|
||||
@ -35,7 +35,7 @@ tap.test('should respect ttl', async (tools) => {
|
||||
);
|
||||
const result = await testLevelCache.retrieveCacheEntryByKey('mykey');
|
||||
expect(result.contents.toString()).toEqual('heythere');
|
||||
await tools.delayFor(1100);
|
||||
await tools!.delayFor(1100);
|
||||
const result2 = await testLevelCache.retrieveCacheEntryByKey('mykey');
|
||||
expect(result2).toBeNull();
|
||||
});
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/levelcache',
|
||||
version: '3.1.1',
|
||||
description: 'A versatile caching solution offering multi-level storage utilizing memory, disk, and Amazon S3 for efficient data management and backup.'
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './levelcache.plugins.js';
|
||||
import * as paths from './levelcache.paths.js';
|
||||
import { AbstractCache } from './levelcache.abstract.classes.cache.js';
|
||||
import { ILevelCacheConstructorOptions, LevelCache } from './levelcache.classes.levelcache.js';
|
||||
import { type ILevelCacheConstructorOptions, LevelCache } from './levelcache.classes.levelcache.js';
|
||||
import { CacheEntry } from './levelcache.classes.cacheentry.js';
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as plugins from './levelcache.plugins.js';
|
||||
import { AbstractCache } from './levelcache.abstract.classes.cache.js';
|
||||
import { CacheEntry } from './levelcache.classes.cacheentry.js';
|
||||
import { ILevelCacheConstructorOptions, LevelCache } from './levelcache.classes.levelcache.js';
|
||||
import { type ILevelCacheConstructorOptions, LevelCache } from './levelcache.classes.levelcache.js';
|
||||
|
||||
export class CacheMemoryManager extends AbstractCache {
|
||||
private levelCacheRef: LevelCache;
|
||||
|
@ -42,16 +42,18 @@ export class CacheS3Manager extends AbstractCache {
|
||||
}
|
||||
|
||||
public async retrieveCacheEntryByKey(keyArg: string): Promise<CacheEntry> {
|
||||
const jsonFileString = (await this.s3CacheDir.fastGet(encodeURIComponent(keyArg))).toString();
|
||||
const jsonFileString = (await this.s3CacheDir.fastGet({
|
||||
path: encodeURIComponent(keyArg),
|
||||
})).toString();
|
||||
const cacheEntry = CacheEntry.fromStorageJsonString(jsonFileString);
|
||||
return cacheEntry;
|
||||
}
|
||||
|
||||
public async storeCacheEntryByKey(keyArg: string, cacheEntryArg: CacheEntry) {
|
||||
await this.s3CacheDir.fastStore(
|
||||
encodeURIComponent(keyArg),
|
||||
cacheEntryArg.toStorageJsonString()
|
||||
);
|
||||
await this.s3CacheDir.fastPut({
|
||||
path: encodeURIComponent(keyArg),
|
||||
contents: cacheEntryArg.toStorageJsonString()
|
||||
});
|
||||
}
|
||||
|
||||
public async checkKeyPresence(keyArg: string): Promise<boolean> {
|
||||
@ -66,7 +68,9 @@ export class CacheS3Manager extends AbstractCache {
|
||||
|
||||
public async deleteCacheEntryByKey(keyArg: string) {
|
||||
if (this.status === 'active') {
|
||||
await this.s3CacheDir.fastRemove(encodeURIComponent(keyArg));
|
||||
await this.s3CacheDir.fastRemove({
|
||||
path: encodeURIComponent(keyArg),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +80,8 @@ export class CacheS3Manager extends AbstractCache {
|
||||
public async cleanOutdated() {}
|
||||
|
||||
public async cleanAll() {
|
||||
await this.s3CacheDir.deleteWithAllContents();
|
||||
await this.s3CacheDir.delete({
|
||||
mode: 'permanent',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export class CacheRouter {
|
||||
/**
|
||||
* gets the relevant cache to perform a store action on
|
||||
*/
|
||||
async getCacheForStoreAction (keyArg: string, cacheEntry: CacheEntry): Promise<AbstractCache> {
|
||||
async getCacheForStoreAction(keyArg: string, cacheEntry: CacheEntry): Promise<AbstractCache> {
|
||||
let returnCache: AbstractCache;
|
||||
const mbToBytesMultiplier = 1000 * 1000;
|
||||
const maxMemoryBytes = this.levelCacheRef.options.maxMemoryStorageInMB * mbToBytesMultiplier;
|
||||
@ -47,7 +47,7 @@ export class CacheRouter {
|
||||
/**
|
||||
* gets the relevant cache to perform a retrieval action on
|
||||
*/
|
||||
async getCacheForRetrieveAction (keyArg: string): Promise<AbstractCache> {
|
||||
async getCacheForRetrieveAction(keyArg: string): Promise<AbstractCache> {
|
||||
const done = plugins.smartpromise.defer<AbstractCache>();
|
||||
const returnCache = this.cacheKeyMap.getByKey(keyArg);
|
||||
if (!returnCache && this.levelCacheRef.options.persistentCache) {
|
||||
|
@ -15,7 +15,7 @@ export interface ILevelCacheConstructorOptions {
|
||||
maxDiskStorageInMB?: number;
|
||||
maxS3StorageInMB?: number;
|
||||
diskStoragePath?: string;
|
||||
s3Config?: plugins.smartbucket.ISmartBucketConfig;
|
||||
s3Config?: plugins.tsclass.storage.IS3Descriptor;
|
||||
s3BucketName?: string;
|
||||
forceLevel?: 'memory' | 'disk' | 's3';
|
||||
expirationInMs?: number;
|
||||
@ -46,7 +46,7 @@ export class LevelCache extends AbstractCache {
|
||||
maxMemoryStorageInMB: 0.5,
|
||||
maxDiskStorageInMB: 10,
|
||||
maxS3StorageInMB: 50,
|
||||
...optionsArg
|
||||
...optionsArg,
|
||||
};
|
||||
this.init();
|
||||
}
|
||||
|
@ -3,17 +3,17 @@ import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartbucket from '@pushrocks/smartbucket';
|
||||
import * as smartcache from '@pushrocks/smartcache';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartjson from '@pushrocks/smartjson';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
import * as taskbuffer from '@pushrocks/taskbuffer';
|
||||
// @push.rocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as smartbucket from '@push.rocks/smartbucket';
|
||||
import * as smartcache from '@push.rocks/smartcache';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartjson from '@push.rocks/smartjson';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
import * as smartunique from '@push.rocks/smartunique';
|
||||
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||
|
||||
export {
|
||||
lik,
|
||||
@ -27,3 +27,10 @@ export {
|
||||
smartunique,
|
||||
taskbuffer,
|
||||
};
|
||||
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
};
|
||||
|
@ -1,8 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user