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
1
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.5 to 1.10.6

2

package.json
{
"name": "bun-sqlite-key-value",
"version": "1.10.5",
"version": "1.10.6",
"author": {

@@ -5,0 +5,0 @@ "name": "Gerold Penz",

@@ -26,2 +26,3 @@ # Bun SQLite Key Value

- [`get()`](#read-value)
- [`getSet()`](#read-and-write-value-in-one-step)
- [`getValues()`](#read-multiple-values)

@@ -226,2 +227,44 @@ - [`getRandomValue()`](#read-random-value)

## Read and Write Value (in one step)
```typescript
getSet(key: string, value: any, ttlMs?: number)
```
Atomically sets key to value and returns the old value stored at key.
Inspired by: https://docs.keydb.dev/docs/commands/#getset
### key
The key must be a string.
### value
The value can be any object that can be serialized with
[v8](https://github.com/nodejs/node/blob/main/doc/api/v8.md#serialization-api).
This means that not only simple data types (string, number) are possible,
but also more complex types such as sets or maps.
You can find a list of the
[supported data types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types) here.
### ttlMs (optional)
"Time to live" in milliseconds. 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.set("key-1", "string-value-1")
store.getSet("key-1", "string-value-2")) // --> "string-value-1"
store.get("key-1") // --> "string-value-2"
```
## Read Multiple Values

@@ -1047,5 +1090,5 @@

store.hmGet(KEY_1, ["field-1", "field-100"]) // --> {
"field-1": "value-1",
"field-100": undefined,
}
// "field-1": "value-1",
// "field-100": undefined,
// }
```

@@ -1083,3 +1126,3 @@

const settingItems = settingsStore.getItems()
console.log(settingItems) // -> [
console.log(settingItems) // --> [
// {key: "language", value: "de"},

@@ -1092,3 +1135,3 @@ // {key: "page-size", value: "A4"},

const languageValues = languagesStore.getValues()
console.log(languageValues) // -> [ "German", "English", "Italian" ]
console.log(languageValues) // --> [ "German", "English", "Italian" ]

@@ -1098,3 +1141,3 @@ // Read current language

const currentLanguage = languagesStore.get(languageKey)
console.log(`Current language: "${currentLanguage}"`) // -> Current language: "German"
console.log(`Current language: "${currentLanguage}"`) // --> Current language: "German"

@@ -1101,0 +1144,0 @@ // Close DBs

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