Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Resolves #43.

checkM(Gen.anyInt) { salt =>
for {
cache <- Cache.make(100, Duration.Infinity, Lookup(hash(salt)))
_ <- ZIO.foreach(1 to 100)(cache.get)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking: maybe capture the count here just to show, after invalidateAll, the count has changed to 0.

for {
   cache <- Cache.make(100, Duration.Infinity, Lookup(hash(salt)))
   _     <- ZIO.foreach(1 to 100)(cache.get)
   size1 <- cache.size
   _     <- cache.invalidateAll
   size2 <- cache.size
} yield assertTrue(size1 == 100) && assertTrue(size2 == 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've got other tests, particularly the one for size below`, to verify that when we add items to the cache they really are included in the cache and reflected in the cache size so we don't need to test that again here.

@adamgfraser adamgfraser merged commit 9931b53 into zio:master Sep 26, 2021
adamgfraser added a commit that referenced this pull request Mar 18, 2022
* 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]>

* ZIO 2.0.0-RC3

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]>
vigoo added a commit that referenced this pull request Jun 25, 2022
* 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]>
@adamgfraser adamgfraser deleted the 43 branch January 1, 2023 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to clear the cache

2 participants