diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 3c94c19..0000000 --- a/.editorconfig +++ /dev/null @@ -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 diff --git a/.gitignore b/.gitignore index 342a59c..20e0d0c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 40d5bcd..0000000 --- a/LICENSE +++ /dev/null @@ -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. diff --git a/README.md b/README.md index 4762969..04ead2e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ In-memory key value store that saves your data to disk using JSON. go get git.akyoto.dev/go/data ``` -## Example +## Usage ```go // User type @@ -44,6 +44,20 @@ for user := range users.All() { {"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 ``` @@ -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: -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. 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 diff --git a/go.mod b/go.mod index dfb4958..0d5c0d8 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ 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 diff --git a/go.sum b/go.sum index a8eadc3..9fc2547 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,2 @@ -git.akyoto.dev/go/assert v0.1.1 h1:F0IO7RxXVfV86Y7bwLsd+C5Ar3X0XCJIuywyiCrk8ms= -git.akyoto.dev/go/assert v0.1.1/go.mod h1:Zr/UFuiqmqRmFFgpBGwF71jbzb6iYJfXFeePYHGtWsg= +git.akyoto.dev/go/assert v0.1.3 h1:QwCUbmG4aZYsNk/OuRBz1zWVKmGlDUHhOnnDBfn8Qw8= +git.akyoto.dev/go/assert v0.1.3/go.mod h1:0GzMaM0eURuDwtGkJJkCsI7r2aUKr+5GmWNTFPgDocM=