New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bun-sqlite-key-value

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-sqlite-key-value - npm Package Compare versions

Comparing version 1.10.3 to 1.10.4

3

dist/index.d.ts

@@ -103,2 +103,5 @@ import { Database } from "bun:sqlite";

}, ttlMs?: number): void;
hmGet<T = any>(key: string, fields: string[]): {
[field: string]: T | undefined;
} | undefined;
}

@@ -434,2 +434,12 @@ // src/index.ts

}
hmGet(key, fields) {
const map = this.get(key);
if (map === undefined)
return;
const result = {};
fields.forEach((field) => {
result[field] = map.get(field);
});
return result;
}
}

@@ -436,0 +446,0 @@ export {

4

package.json
{
"name": "bun-sqlite-key-value",
"version": "1.10.3",
"version": "1.10.4",
"author": {

@@ -25,3 +25,3 @@ "name": "Gerold Penz",

"description": "A super fast key-value store with SQLite that uses bun:sqlite and v8 as faster JSON replacement.",
"homepage": "https://github.com/gerold-penz/bun-sqlite-key-value",
"homepage": "https://gerold-penz.github.io/bun-sqlite-key-value/",
"keywords": [

@@ -28,0 +28,0 @@ "Bun",

@@ -8,3 +8,3 @@ # Bun SQLite Key Value

[SQLite implementation](https://bun.sh/docs/api/sqlite) makes Bun-SQLite-Key-Value
perfect for a fast storage and cache solution with TTL support.
perfect for a fast and reliable storage and cache solution with TTL support.
*You need [Bun](https://bun.sh/) to be able to use this package.*

@@ -57,6 +57,8 @@

- String
- ['append()'](#append)
- [`append()`](#append)
- Hash (Map Object)
- [`hSet()`](#hash-map-object---write-value-)
- [`hGet()`](#hash-map-object---read-value-)
- [`hmSet()`](#hash-map-object---write-multiple-values-)
- [`hmGet()`](#hash-map-object---read-multiple-values-)
- Extended database topics

@@ -892,2 +894,6 @@ - [Multiple Databases](#multiple-databases)

Do not use it with several large amounts of data or blobs.
This is because the entire data record with all fields is always read and written.
It is better to use `setValues()` and `getValues()` for large amounts of data.
### key

@@ -946,2 +952,6 @@

Do not use it with several large amounts of data or blobs.
This is because the entire data record with all fields is always read and written.
It is better to use `setValues()` and `getValues()` for large amounts of data.
### key

@@ -969,2 +979,74 @@

## Hash (Map Object) - Write Multiple Values
```typescript
hmSet(key: string, fields: {[field: string]: T}, ttlMs?: number)
```
Like `hSet()`, with the difference that several fields
are written to the database in one go.
### key
The key must be a string.
### fields
Object with field names (keys) and values.
### ttlMs (optional)
"Time to live" in milliseconds (for the database line, marked with `key`).
After this time, the item becomes invalid and is deleted from the database
the next time it is accessed or when the application is started.
Set the value to 0 if you want to explicitly deactivate the process.
### Example
```typescript
import { BunSqliteKeyValue } from "bun-sqlite-key-value"
const store = new BunSqliteKeyValue()
store.hmSet("my-key", {
"field-1": "value-1",
"field-2": "value-2",
"field-3": "value-3"
})
```
## Hash (Map Object) - Read Multiple Values
```typescript
hmGet(key: string, fields: fields: string[])
```
Like `hGet()`, with the difference that several fields are read in one go.
### key
The key must be a string.
### fields
Array with field names.
### Example
```typescript
import { BunSqliteKeyValue } from "bun-sqlite-key-value"
const store = new BunSqliteKeyValue()
store.hmSet("my-key", {
"field-1": "value-1",
"field-2": "value-2"
})
store.hmGet(KEY_1, ["field-1", "field-100"]) // --> {
"field-1": "value-1",
"field-100": undefined,
}
```
## Multiple Databases

@@ -971,0 +1053,0 @@

@@ -662,3 +662,3 @@ import { Database, type Statement } from "bun:sqlite"

const map = this.get<Map<string, T>>(key)
if (map === undefined) return undefined
if (map === undefined) return
return map.get(field)

@@ -682,6 +682,14 @@ }

// ToDo: hmGet()
// Do not use it with several large amounts of data or blobs.
// This is because the entire data record with all fields is always read and written.
// Inspired by: https://docs.keydb.dev/docs/commands/#hmget
hmGet<T = any>(key: string, fields: string[]): {[field: string]: T | undefined} | undefined {
const map = this.get<Map<string, T>>(key)
if (map === undefined) return
const result: {[field: string]: T | undefined} = {}
fields.forEach((field) => {
result[field] = map.get(field)
})
return result
}

@@ -688,0 +696,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc