diff --git a/README.md b/README.md index bd0757b..cd066e8 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -## in-memdb +## incache -The `inmemdb` package provides a simple in-memory database implementation in Go. It can be used as a package in other Go projects to store key-value pairs in memory. The package is safe to use concurrently with multiple goroutines. +The `incache` package provides a simple cache implementation in Go. It can be used as a package in other Go projects to store key-value pairs in memory. The package is safe to use concurrently with multiple goroutines. ### Installation To use this package in your Go project, you can install it using `go get`: ```bash -go get github.com/knbr13/inmemdb +go get github.com/knbr13/incache ``` ### Usage @@ -19,12 +19,12 @@ import ( "fmt" "time" - inmemdb "github.com/knbr13/in-memdb" + incache "github.com/knbr13/incache" ) func main() { // Create a new Cache Builder - cb := inmemdb.New[string, string](3) // 3 is the maximum number of key-value pairs the cache can hold + cb := incache.New[string, string](3) // 3 is the maximum number of key-value pairs the cache can hold // Build the Cache db := cb.Build() @@ -53,12 +53,12 @@ func main() { db.Delete("key1") // Transfer data to another database - anotherCB := inmemdb.New[string, string](2) + anotherCB := incache.New[string, string](2) anotherDB := anotherCB.Build() db.TransferTo(anotherDB) // Copy data to another database - copyCB := inmemdb.New[string, string](2) + copyCB := incache.New[string, string](2) copyDB := copyCB.Build() anotherDB.CopyTo(copyDB) diff --git a/cache.go b/cache.go index 42a3b59..e2121f3 100644 --- a/cache.go +++ b/cache.go @@ -1,4 +1,4 @@ -package inmemdb +package incache import ( "sync" @@ -79,7 +79,7 @@ func (b *CacheBuilder[K, V]) Build() Cache[K, V] { case Manual: return newManual[K, V](b) default: - panic("in-memdb: unknown evict-type") + panic("incache: unknown evict-type") } } diff --git a/go.mod b/go.mod index dc7292c..2107d13 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/knbr13/in-memdb +module github.com/knbr13/incache go 1.22.0 diff --git a/mcache.go b/mcache.go index 4d5c7d6..e311841 100644 --- a/mcache.go +++ b/mcache.go @@ -1,4 +1,4 @@ -package inmemdb +package incache import ( "time" @@ -16,7 +16,7 @@ type valueWithTimeout[V any] struct { expireAt *time.Time } -// New creates a new in-memory database instance with optional configuration provided by the specified options. +// New creates a new cache instance with optional configuration provided by the specified options. // The database starts a background goroutine to periodically check for expired keys based on the configured time interval. func newManual[K comparable, V any](cacheBuilder *CacheBuilder[K, V]) *MCache[K, V] { db := &MCache[K, V]{ @@ -240,7 +240,6 @@ func (c *MCache[K, V]) expireKeys() { } } -// Purge clears the cache completely. func (c *MCache[K, V]) Purge() { if c.timeInterval > 0 { c.stopCh <- struct{}{} // Signal the expiration goroutine to stop diff --git a/mcache_test.go b/mcache_test.go index 040f967..a0b8720 100644 --- a/mcache_test.go +++ b/mcache_test.go @@ -1,4 +1,4 @@ -package inmemdb +package incache import ( "testing"