NodeJS Client library for S3 Cache Bridge Server
npm install @yingyeothon/s3-cache-bridge-clientNodeJS Client library for S3 Cache Bridge.
``typescript
import S3cb from "@yingyeothon/s3-cache-bridge-client";
const cb = S3cb({
apiUrl: "http://your-server-address/",
apiId: "api-id",
apiPassword: "api-password",
});
// Get a file.
await cb.get("hello");
// Put a new content into the file.
await cb.put("hello", "new content");
// Delete a file.
await cb.delete("hello");
`
| Name | Description | Example |
| ---------- | ---------------------------------------------------------------------- | ------------------------------------ |
| get | Get a file as string. | cb.get(key) |buffer
| getBuffer | Get a file as . | cb.getBuffer(key) |cb.download(key, localPath)
| download | Download a file into local. | |cb.put(key, body: string)
| put | Put a content into the file. | |cb.append(key, body: string)
| append | Append a content into the file. | |cb.del(key)
| del | Delete a file. | |cb.patch(key, operation: JSON_MOD)
| patch | Patch a JSON file using json-mod. | |cb.invalidate(key)
| invalidate | Invalidate a cache file in bridge server. | |cb.sync(key)
| sync | Upload a cache file into S3 right now. | |cb.lock(key)
| lock | Acquire a lock of key. | |cb.unlock(key)` |
| unlock | Release a lock of key. |
MIT