Skip to content

Commit

Permalink
Tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
gerold-penz committed Aug 1, 2024
1 parent a1b2ca9 commit b936735
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,7 @@ store.decr("my-key") // --> 8
append(key: string, value: string, ttlMs?: number): number
```

If key already exists and is a string, this command appends the
value at the end of the string.
If key already exists, this command appends the value at the end of the string.
If key does not exist it is created and set as an empty string,
so `append()` will be similar to `set()` in this special case.
Inspired by: https://docs.keydb.dev/docs/commands/#append
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export class BunSqliteKeyValue {
}


// If key already exists and is a string, this command appends the value at the end of the string.
// If key already exists, this command appends the value at the end of the string.
// If key does not exist it is created and set as an empty string,
// so `append()` will be similar to `set()` in this special case.
// Returns the length of the string after the append operation.
Expand Down
4 changes: 4 additions & 0 deletions tests/memory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,8 @@ test("Append", async () => {
expect(store.get<string>(KEY_1)).toEqual(STRING_VALUE_1 + STRING_VALUE_2)
await Bun.sleep(40)
expect(store.getCountValid()).toEqual(0)

store.set<number>(KEY_1, 1)
store.append(KEY_1, " million")
expect(store.get<string>(KEY_1)).toEqual("1 million")
})

0 comments on commit b936735

Please sign in to comment.