diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 585af53..60f9535 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -71,6 +71,11 @@ jobs: services: dragonfly: image: docker.dragonflydb.io/dragonflydb/dragonfly + options: >- + --health-cmd "nc -z localhost 6379" + --health-interval 10s + --health-timeout 5s + --health-retries 5 keydb: image: eqalpha/keydb @@ -223,6 +228,6 @@ jobs: sleep 120 curl -L https://go.dev/dl/go1.22.0.linux-amd64.tar.gz | tar -C /usr/local -xzf - - name: Execute Tests - run: /usr/local/go/bin/go test -v -race -covermode=atomic -coverprofile=coverage.out ./drivers/cache + run: /usr/local/go/bin/go test -v -race -covermode=atomic -coverprofile=coverage.out ./cache - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 diff --git a/README.md b/README.md index b5b19dc..0fcea8d 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,27 @@ Hord is designed to be a database-agnostic library that provides a common interf - **Testing with Mock Driver**: Hord provides a mock driver in the `mock` package, which can be used for testing purposes. The `mock` driver allows users to define custom functions executed when calling the `Database` interface methods, making it easier to test code that relies on the Hord interface. - **Documentation**: Each driver comes with its own package documentation, providing guidance on how to use and configure the driver. +### Evolving Features + +- **Cache Implementations**: Combine database drivers with pre-defined cache implementations. + ## Database Drivers: | Database | Support | Comments | Protocol Compatible Alternatives | | -------- | ------- | -------- | -------------------------------- | | [BoltDB](https://github.com/etcd-io/bbolt) | ✅ | | | | [Cassandra](https://cassandra.apache.org/) | ✅ | | [ScyllaDB](https://www.scylladb.com/), [YugabyteDB](https://www.yugabyte.com/), [Azure Cosmos DB](https://learn.microsoft.com/en-us/azure/cosmos-db/introduction) | -| [Couchbase](https://www.couchbase.com/) | Pending ||| | Hashmap | ✅ | Optionally allows storing to YAML or JSON file || | Mock | ✅ | Mock Database interactions within unit tests || | [NATS](https://nats.io/) | ✅ | Experimental || | [Redis](https://redis.io/) | ✅ || [Dragonfly](https://www.dragonflydb.io/), [KeyDB](https://docs.keydb.dev/) | +## Caching Implementations + +| Cache Strategy | Comments | +| -------------- | -------- | +| Look Aside | Cache is checked before database, if not found in cache, database is checked and cache is updated | + ## Usage To use Hord, import it as follows: diff --git a/drivers/cache/cache.go b/cache/cache.go similarity index 98% rename from drivers/cache/cache.go rename to cache/cache.go index b979113..ecefa79 100644 --- a/drivers/cache/cache.go +++ b/cache/cache.go @@ -88,7 +88,7 @@ import ( "errors" "github.com/madflojo/hord" - "github.com/madflojo/hord/drivers/cache/lookaside" + "github.com/madflojo/hord/cache/lookaside" ) // CacheType is the type of cache to use. diff --git a/drivers/cache/cache_test.go b/cache/cache_test.go similarity index 100% rename from drivers/cache/cache_test.go rename to cache/cache_test.go diff --git a/drivers/cache/common_test.go b/cache/common_test.go similarity index 100% rename from drivers/cache/common_test.go rename to cache/common_test.go diff --git a/drivers/cache/lookaside/lookaside.go b/cache/lookaside/lookaside.go similarity index 100% rename from drivers/cache/lookaside/lookaside.go rename to cache/lookaside/lookaside.go diff --git a/drivers/cache/lookaside/lookaside_test.go b/cache/lookaside/lookaside_test.go similarity index 100% rename from drivers/cache/lookaside/lookaside_test.go rename to cache/lookaside/lookaside_test.go