From fb9095972fef58478521b1474b526997bd083eca Mon Sep 17 00:00:00 2001 From: zekroTJA Date: Sat, 25 Mar 2023 11:03:15 +0000 Subject: [PATCH] add docs --- CHANGELOG.md | 12 ------------ timedmap.go | 6 ++++++ 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index cc3fcf4..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -## v1.4.0 - -- Add `SetExpires` method to match `Section` interface and match naming scheme of the other expire-related endpoints. - → Hence, **`SetExpire` is now deprecated and will be removed in the next version.** Please use `SetExpires` instead. - -- Make use of `sync.Pool` to re-use `element` instances instead of creating new ones on each new element creation and passing them to the GC after deletion. - -- Add `StartCleanerInternal` and `StartCleanerExternal` endpoints to be able to re-start the internal cleanup loop with new specifications. - -## v1.3.1 - -- Fix `concurrent map read and map write` panic when accessing the map concurrently while getting an existing key, which is expired at the time. [#4] \ No newline at end of file diff --git a/timedmap.go b/timedmap.go index 5aca089..20b6ca4 100644 --- a/timedmap.go +++ b/timedmap.go @@ -57,6 +57,12 @@ func New(cleanupTickTime time.Duration, tickerChan ...<-chan time.Time) *TimedMa return newTimedMap(make(map[keyWrap]*element), cleanupTickTime, tickerChan) } +// FromMap creates a new TimedMap containing the given +// keys and values from the passed map m. All key-value +// pairs will be assigned the given expiration. +// +// Returns ErrValueNoMap if the given value for m is +// not of type map. func FromMap( m interface{}, expiration time.Duration,