-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement Cache#invalidateAll (#51) * implement Cache#invalidateAll * format * Added size to `CacheStats`. (#53) * Added size and capacity to `CacheStats`. * Removed `capacity` from stats. * Update Node.js to v14.18.0 (#55) Co-authored-by: Renovate Bot <[email protected]> * Add `refresh` method to trigger a lookup call. (#52) * First attempt to resolve #42 * Fixed a concurrency issue * Refactoring * Minor refactorings, scalafmt & sbt upgrades * Fixing build * Refactoring: replaced vars with ref * Reformatted build.sbt to fix build. * Fixing build * Fixing build * Updated docs * Fixed formatting and addressed PR comments. * Fixed docs * Added a unit test for `refresh` method. * Improved docs * Minor improvement * Bumped scalafmt * Bumped scalajs * Update Node.js to v14.18.1 (#58) Co-authored-by: Renovate Bot <[email protected]> * Update actions/checkout action to v2.3.5 (#59) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16 (#61) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.13.0 (#62) Co-authored-by: Renovate Bot <[email protected]> * Update actions/checkout action to v2.4.0 (#64) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.13.1 (#65) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.13.2 (#68) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.14.0 (#70) Co-authored-by: Renovate Bot <[email protected]> * Update actions/checkout action (#72) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.14.1 (#73) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.14.2 (#74) Co-authored-by: Renovate Bot <[email protected]> * Update hmarr/auto-approve-action action to v2.2.0 (#77) Co-authored-by: Renovate Bot <[email protected]> * Update actions/checkout action to v3.0.1 (#82) Co-authored-by: Renovate Bot <[email protected]> * Update actions/checkout action to v3.0.2 (#83) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.15.0 (#84) Co-authored-by: Renovate Bot <[email protected]> * Update Node.js to v16.15.1 (#87) Co-authored-by: Renovate Bot <[email protected]> * Cache managed resource (#71) * Add .bsp to .gitignore * Extract KeySet and MapKey out of Cache Because they probably going to be shared with ManagedCache * define interface for a ManagedCache * Copy/Paste: cache implementation and cache test for managedCache * Adapt cache implementation and test for ManagedCache * make ManagedCache.get return Managed[Error, Value] instead of UIO[Managed[Error, Value]] * Make ManagedCache work on 2.11 and Scala 3 * Fix doc after Adam's review * fixup! Fix doc after Adam's review * fixup! Fix doc after Adam's review * fix managed cache invalidate not being lazy (#88) * run finalizer after acquire fails * fix compilation issue * format Co-authored-by: Adam Fraser <[email protected]> Co-authored-by: Terry L <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: LUC DUZAN <[email protected]>
- Loading branch information
1 parent
df6687f
commit 9f507ad
Showing
13 changed files
with
1,590 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ jobs: | |
timeout-minutes: 30 | ||
steps: | ||
- name: Checkout current branch | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Scala and Java | ||
|
@@ -33,7 +33,7 @@ jobs: | |
timeout-minutes: 60 | ||
steps: | ||
- name: Checkout current branch | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
- name: Setup Scala and Java | ||
uses: olafurpg/setup-scala@v13 | ||
- name: Cache scala dependencies | ||
|
@@ -52,7 +52,7 @@ jobs: | |
platform: ['JVM', 'JS', 'Native'] | ||
steps: | ||
- name: Checkout current branch | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Scala and Java | ||
|
@@ -82,7 +82,7 @@ jobs: | |
if: github.event_name != 'pull_request' | ||
steps: | ||
- name: Checkout current branch | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Scala and Java | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16.14.2 | ||
16.15.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package zio.cache | ||
|
||
/** | ||
* A `KeySet` is a sorted set of keys in the cache ordered by last access. | ||
* For efficiency, the set is implemented in terms of a doubly linked list | ||
* and is not safe for concurrent access. | ||
*/ | ||
private[cache] final class KeySet[Key] { | ||
private[this] var head: MapKey[Key] = null | ||
private[this] var tail: MapKey[Key] = null | ||
|
||
/** | ||
* Adds the specified key to the set. | ||
*/ | ||
def add(key: MapKey[Key]): Unit = | ||
if (key ne tail) { | ||
if (tail ne null) { | ||
val previous = key.previous | ||
val next = key.next | ||
if (next ne null) { | ||
key.next = null | ||
if (previous ne null) { | ||
previous.next = next | ||
next.previous = previous | ||
} else { | ||
head = next | ||
head.previous = null | ||
} | ||
} | ||
tail.next = key | ||
key.previous = tail | ||
tail = key | ||
} else { | ||
head = key | ||
tail = key | ||
} | ||
} | ||
|
||
/** | ||
* Removes the lowest priority key from the set. | ||
*/ | ||
def remove(): MapKey[Key] = { | ||
val key = head | ||
if (key ne null) { | ||
val next = key.next | ||
if (next ne null) { | ||
key.next = null | ||
head = next | ||
head.previous = null | ||
} else { | ||
head = null | ||
tail = null | ||
} | ||
} | ||
key | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package zio.cache | ||
|
||
/** | ||
* A `MapKey` represents a key in the cache. It contains mutable references | ||
* to the previous key and next key in the `KeySet` to support an efficient | ||
* implementation of a sorted set of keys. | ||
*/ | ||
private[cache] final class MapKey[Key]( | ||
val value: Key, | ||
var previous: MapKey[Key] = null, | ||
var next: MapKey[Key] = null | ||
) |
Oops, something went wrong.