Cleaned up repository

This commit is contained in:
Eduard Urbach 2024-06-26 14:02:08 +02:00
parent 3fed61059b
commit 81bfcb9741
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
6 changed files with 33 additions and 38 deletions

View File

@ -1,9 +0,0 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

19
.gitignore vendored
View File

@ -1,16 +1,7 @@
# Ignore everything
* *
# But not these files...
!/.gitignore
!/.editorconfig
!*.go
!go.sum
!go.mod
!README.md
!LICENSE
# ...even if they are in subdirectories
!*/ !*/
!*.go
!*.mod
!*.sum
!*.md
!.gitignore

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) 2023 Eduard Urbach
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -8,7 +8,7 @@ In-memory key value store that saves your data to disk using JSON.
go get git.akyoto.dev/go/data go get git.akyoto.dev/go/data
``` ```
## Example ## Usage
```go ```go
// User type // User type
@ -44,6 +44,20 @@ for user := range users.All() {
{"name":"User 3"} {"name":"User 3"}
``` ```
## Tests
```
PASS: TestCollection
PASS: TestCollection/All
PASS: TestCollection/Filter
PASS: TestCollection/Get
PASS: TestCollection/Exists
PASS: TestCollection/Parallel_Get_and_Set
PASS: TestCollection/Delete
PASS: TestFilePersistence
coverage: 84.1% of statements
```
## Benchmarks ## Benchmarks
``` ```
@ -71,8 +85,16 @@ Every collection uses one goroutine to check the "dirty" flag, write the new con
The biggest advantage of `data.File` is that it scales well with the number of requests: The biggest advantage of `data.File` is that it scales well with the number of requests:
Suppose `n` is the number of write requests and `io` is the time it takes for one write. Immediate writes would require `O(n * io)` time to complete all writes but the async behavior makes it `O(n)`. Suppose `n` is the number of write requests and `io` is the time it takes for one write. Immediate writes would require `n * io` time to complete all writes but the async behavior makes it a constant `io`.
You should use `data.File` if you have a permanently running process such as a web server where end users expect quick responses and background work can happen after the user request has already been dealt with. You should use `data.File` if you have a permanently running process such as a web server where end users expect quick responses and background work can happen after the user request has already been dealt with.
Make sure you `defer collection.Sync()` to ensure that queued writes will be handled when the process ends. Make sure you `defer collection.Sync()` to ensure that queued writes will be handled when the process ends.
## License
Please see the [license documentation](https://akyoto.dev/license).
## Copyright
© 2023 Eduard Urbach

4
go.mod
View File

@ -1,5 +1,5 @@
module git.akyoto.dev/go/data module git.akyoto.dev/go/data
go 1.20 go 1.22
require git.akyoto.dev/go/assert v0.1.1 require git.akyoto.dev/go/assert v0.1.3

4
go.sum
View File

@ -1,2 +1,2 @@
git.akyoto.dev/go/assert v0.1.1 h1:F0IO7RxXVfV86Y7bwLsd+C5Ar3X0XCJIuywyiCrk8ms= git.akyoto.dev/go/assert v0.1.3 h1:QwCUbmG4aZYsNk/OuRBz1zWVKmGlDUHhOnnDBfn8Qw8=
git.akyoto.dev/go/assert v0.1.1/go.mod h1:Zr/UFuiqmqRmFFgpBGwF71jbzb6iYJfXFeePYHGtWsg= git.akyoto.dev/go/assert v0.1.3/go.mod h1:0GzMaM0eURuDwtGkJJkCsI7r2aUKr+5GmWNTFPgDocM=