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.3.10 to 1.3.11

2

examples/ttlCachingExample.ts
import { BunSqliteKeyValue } from "../src"
const store: BunSqliteKeyValue = new BunSqliteKeyValue(undefined, {ttlMs: 1000})
const store = new BunSqliteKeyValue(undefined, {ttlMs: 1000})

@@ -6,0 +6,0 @@ const KEY = "cache-key"

{
"name": "bun-sqlite-key-value",
"version": "1.3.10",
"version": "1.3.11",
"author": "Gerold Penz<gerold@gp-softwaretechnik.at>",

@@ -5,0 +5,0 @@ "repository": {

@@ -45,7 +45,4 @@ # Bun SQLite Key Value

## Documentation
## Open Database
### Open Database
```typescript

@@ -57,3 +54,3 @@ const store = new BunSqliteKeyValue([filename], [options])

#### filename (optional)
### filename (optional)

@@ -63,3 +60,3 @@ The full path of the SQLite database to open.

#### options (optional)
### options (optional)

@@ -79,3 +76,3 @@ `readonly?: boolean`:

#### Example
### Example

@@ -94,3 +91,3 @@ ```typescript

### Write Value
## Write Value

@@ -103,7 +100,7 @@ ```typescript

#### key
### key
The key must be a string.
#### value
### value

@@ -117,3 +114,3 @@ The value can be any object that can be serialized with

#### ttlMs (optional)
### ttlMs (optional)

@@ -125,3 +122,3 @@ "Time to live" in milliseconds. After this time,

#### Example
### Example

@@ -142,3 +139,3 @@ ```typescript

### Read Value
## Read Value

@@ -151,7 +148,7 @@ ```typescript

#### key
### key
The key must be a string.
#### Example
### Example

@@ -169,3 +166,3 @@ ```typescript

### Read Item
## Read Item

@@ -178,7 +175,7 @@ Reads the key and the value from the database.

#### key
### key
The key must be a string.
#### Example
### Example

@@ -196,3 +193,3 @@ ```typescript

### Read Values
## Read Values

@@ -205,3 +202,3 @@ ```typescript

#### startsWithOrKeys
### startsWithOrKeys

@@ -219,3 +216,3 @@ `string`: Returns all values in an array whose keys begin with the passed string.

#### Example
### Example

@@ -236,3 +233,3 @@ ```typescript

### Read Items
## Read Items

@@ -244,3 +241,3 @@ ```typescript

#### startsWithOrKeys
### startsWithOrKeys

@@ -259,3 +256,3 @@ `string`: Returns all items (key, value) in an array whose keys begin with

#### Example
### Example

@@ -281,11 +278,10 @@ ```typescript

### Multiple Databases
## Multiple Databases
It is no problem at all to use several databases and access them at the same time.
#### Example
### Example
```typescript
import { BunSqliteKeyValue } from "bun-sqlite-key-value"
import { join } from "node:path"

@@ -340,3 +336,3 @@ import { exists, mkdir } from "node:fs/promises"

### Read and write binary files (images)
## Read and write binary files (images)

@@ -346,5 +342,4 @@ SQLite has no problem with images and other binaries.

### Example
#### Example
```typescript

@@ -368,3 +363,3 @@ import { BunSqliteKeyValue } from "bun-sqlite-key-value"

### Cache values with TTL
## Cache values with TTL

@@ -376,3 +371,3 @@ You can specify a caching period when you open the database.

#### Example
### Example

@@ -382,3 +377,3 @@ ```typescript

const store: BunSqliteKeyValue = new BunSqliteKeyValue(undefined, {ttlMs: 1000})
const store = new BunSqliteKeyValue(undefined, {ttlMs: 1000})

@@ -392,1 +387,65 @@ const KEY = "cache-key"

```
## All Methods
### Database
- `new BunSqliteKeyValue()` --> Open database
- `close()` --> Close database
### Set value
- `set(key: string, value: any)`
- `setValue(key: string, value: any)` --> alias for set()
### Get value
- `get(key: string)`
- `getValue(key: string)` --> alias for get()
### Get item
- `getItem(key: string)` --> Object
### Get items as Array
- `getItems()` --> Array with all items
- `getItems(startsWith: string)` --> Array
- `getItems(keys: string[])` --> Array
- `getItemsArray()` --> alias for getItems()
- `getItemsArray(startsWith: string)` --> alias for getItems()
- `getItemsArray(keys: string[])` --> alias for getItems()
### Get items as Object
- `getItemsObject()` --> Object with all items
- `getItemsObject(startsWith: string)` --> Object
- `getItemsObject(keys: string[])` --> Object
### Get items as Map()
- `getItemsMap()` --> Map with all items
- `getItemsMap(startsWith: string)` --> Map
- `getItemsMap(keys: string[])` --> Map
### Get values as Array
- `getValues()` --> Array with all values
- `getValues(startsWith: string)` --> Array
- `getValues(keys: string[])` --> Array
- `getValuesArray()` --> alias for getValues()
- `getValuesArray(startsWith: string)` --> alias for getValues()
- `getValuesArray(keys: string[])` --> alias for getValues()
### Get values as Set()
- `getValuesSet()` --> Set with all values
- `getValuesSet(startsWith: string)` --> Set
- `getValuesSet(keys: string[])` --> Set
### Delete
- `clear()` --> Delete all items
- `delete(key: string)` --> Delete item
- `delete(keys: string[])` --> Delete items
### Count
- `getCount()` --> Number
- `length` --> alias for getCount()
### Get keys
- `has(key: string)` --> Boolean
- [ ] getKeys() --> Array with all Keys
- [ ] getKeys(startsWith: string) --> Array

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

interface RawItem {
interface Record {
key: string

@@ -42,8 +42,8 @@ value: Buffer | null,

private setItemStatement: Statement
private getItemStatement: Statement<Omit<RawItem, "key">>
private getAllItemsStatement: Statement<RawItem>
private getItemsStartsWithStatement: Statement<RawItem>
private getKeyStatement: Statement<Omit<RawItem, "value">>
// private getAllKeysStatement: Statement<Omit<RawItem, "value">>
// private getKeysStartsWithStatement: Statement<Omit<RawItem, "value">>
private getItemStatement: Statement<Omit<Record, "key">>
private getAllItemsStatement: Statement<Record>
private getItemsStartsWithStatement: Statement<Record>
private getKeyStatement: Statement<Omit<Record, "value">>
// private getAllKeysStatement: Statement<Omit<Record, "value">>
// private getKeysStartsWithStatement: Statement<Omit<Record, "value">>

@@ -189,3 +189,3 @@

getItems<T = any>(startsWithOrKeys?: string | string[]): Item<T>[] | undefined {
let records: RawItem[]
let records: Record[]
if (startsWithOrKeys && typeof startsWithOrKeys === "string") {

@@ -192,0 +192,0 @@ // Filtered items (startsWith)

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