Skip to content

Commit

Permalink
Merge branch 'master' into migrate-to-pekko
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelCemus committed Feb 4, 2024
2 parents c6aa67f + 4c09acb commit dd96717
Show file tree
Hide file tree
Showing 127 changed files with 7,966 additions and 5,239 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sbt --client "+clean; +compile; +Test/compile; +coverage; +test; +coverageReport; +coveralls;"
sbt --client "+clean; +compile; +Test/compile; lint; +coverage; +test; +coverageReport; +coveralls;"
19 changes: 19 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rules = [
ExplicitResultTypes
LeakingImplicitClassVal
NoAutoTupling
NoValInForComprehension
OrganizeImports
ProcedureSyntax
RedundantSyntax
RemoveUnused
]

RemoveUnused {
imports = false // handled by OrganizeImports
}

OrganizeImports {
# Allign with IntelliJ IDEA so that they don't fight each other
groupedImports = Merge
}
168 changes: 168 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
version = "3.7.17"
runner.dialect = scala213
maxColumn = 300

// https://scalameta.org/scalafmt/docs/configuration.html#projectgit
project.git = true

fileOverride {
"glob:**/project/**.scala" {
runner.dialect = scala212
}
"glob:**/*.sbt" {
runner.dialect = sbt1
}
}

// ---------------------
// alignment
// ---------------------
align.preset = most
// align code behind -> e.g. in for ... yield
align.arrowEnumeratorGenerator = true
// multiline strings
align.stripMargin = true
assumeStandardLibraryStripMargin = true
// align also multiline statements
align.multiline = true
// don't break lines just because of alignment
align.allowOverflow = true
// align '='
align.tokens."+" = [
{
code = "="
owners = [{
parents = ["Template"]
}]
}
{
code = "="
owners = [{
regex = "Enumerator\\."
parents = ["Term\\.ForYield"]
}]
}
]
// align vals and types equally
align.treeCategory."Defn.Val" = "given/val/var/def"
align.treeCategory."Defn.Type" = "given/val/var/def"

// ---------------------
// indentation
// ---------------------
// identation of function calls
indent.callSite = 2
// indentation of "if" and "while"
indent.ctrlSite = 2
// identation of definition of parameters in cls and fce
indent.defnSite = 2
// indentation of "extends" and "with"
indent.extendSite = 2
// indent nested match and infix expressions
// this causes issues with // comments, indents them
// indent.relativeToLhsLastLine = [match, infix]
// indentation of multiline nested parentheses
binPack.indentCallSiteOnce = false
binPack.indentCallSiteSingleArg = false


// ---------------------
// indent operator
// ---------------------
// apply indentation exempts only in some cases
//indentOperator.preset = "spray"
// exempt indentation of 2nd and additional lines in special cases
indentOperator.exemptScope = all


// ---------------------
// new lines
// ---------------------
// remove line breaks, leads to horizontal code
//newlines.source = fold
// newlines around statements
newlines.topLevelStatementBlankLines = [
{
blanks = 1
}
{
minBreaks = 1
blanks = 1
}
]
// newlines after package, class, trait header if body is not trivial
newlines.topLevelBodyIfMinStatements = []
newlines.topLevelBodyMinStatements = 2
newlines.beforeTemplateBodyIfBreakInParentCtors = true
// force newline in case/if/while when the body is multiline
newlines.beforeMultiline = keep
newlines.alwaysBeforeElseAfterCurlyIf = false
// break when assignment is multiline
// newlines.forceBeforeMultilineAssign = any
// formatting of bounds of type parameters: upper <:, lower >:, view <%, and context : bounds
newlines.beforeTypeBounds = unfold
// newlines in { case ... => f() } lambdas
// newlines.beforeCurlyLambdaParams = never
// newlines.afterCurlyLambdaParams = squash
// spaces after implicit in fce parameter list
//newlines.implicitParamListModifierForce = [after]
//newlines.avoidForSimpleOverflow = [punct, tooLong, slc]
// skip newlines in the result type
newlines.avoidInResultType = true
// don't put newline before : of the result type if line overflows
newlines.sometimesBeforeColonInMethodReturnType = false
// chains of calls
newlines.selectChains = keep
// in interpolation
newlines.inInterpolation = avoid
// dangling parenteses
danglingParentheses.preset = true
danglingParentheses.exclude = []

// config style arguments
//optIn.configStyleArguments = true
//runner.optimizer.forceConfigStyleOnOffset = 80
//runner.optimizer.forceConfigStyleMinArgCount = 1


// rewrite rules
// - drop redundant braces like { } around a block
// - drop redundant parentheses like ( ) around a statement
// - sort implicit final private lazy
// - prefer for { } yield () over for (;) yield ()
// - organize imports
rewrite.rules = [RedundantBraces, RedundantParens, SortModifiers, PreferCurlyFors, Imports]
rewrite.redundantBraces.stringInterpolation = true
rewrite.imports.sort = scalastyle
rewrite.trailingCommas.style = always
// rewrite tokens to different characters
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}

// vertical align a line breaks
verticalMultiline.atDefnSite = true
verticalMultiline.arityThreshold = 100
verticalMultiline.newlineAfterOpenParen = true

// wrap long standalone comments
comments.wrap = standalone
comments.wrapStandaloneSlcAsSlc = true

// javadoc formatting
docstrings.style = SpaceAsterisk
docstrings.blankFirstLine = yes
docstrings.removeEmpty = true
docstrings.oneline = fold
docstrings.wrapMaxColumn = 80

// all calls in chains start on a new line
includeNoParensInSelectChains = true
// keep chains on multiple lines if already multiline
optIn.breakChainOnFirstMethodDot = true

// scala 3 config
rewrite.scala3.convertToNewSyntax = true
//rewrite.trailingCommas.style = "multiple"
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
Updated to Play `2.9.0` and dropped `Scala 2.12` since it was discontinued from the Play framework.
Minimal supported Java version is now `11`. [#265](https://github.com/KarelCemus/play-redis/pull/265)

Migrated from test framework `specs2` to `scalatest` because specs2 is not friendly to
cross-compilation between Scala 2.13 and Scala 3. Test are uses `testcontainers` to run
standalone, cluster or sentinel instance. However, current redis connector is not friendly
and there are several significant limitations in the implementation, therefore the tests
for cluster are using fixed port mapping and tests for sentinel are disabled since it seems
that sentinel implementation is not fully reliable, therefore sentinel is not officially
supported at this moment. [#273](https://github.com/KarelCemus/play-redis/pull/273)

Installed linters and formatters - scalafmt, scalafix, wartremover. [#275](https://github.com/KarelCemus/play-redis/pull/275)

### [:link: 2.7.0](https://github.com/KarelCemus/play-redis/tree/2.7.0)

SET command supports milliseconds, previous versions used seconds [#247](https://github.com/KarelCemus/play-redis/issues/247)
Expand All @@ -30,17 +40,17 @@ Note: This should not be a breaking change since it was not possible to properly
the value in Java without encountering the exception.

Introduced another source `aws-cluster`, which is a cluster with nodes defined by DNS record. For example,
Amazon AWS uses this kind of cluster definition. Therefore this type of a cluster resolves
Amazon AWS uses this kind of cluster definition. Therefore this type of a cluster resolves
a domain main to extract all nodes. See [#221](https://github.com/KarelCemus/play-redis/pull/221) for more details.

### [:link: 2.5.0](https://github.com/KarelCemus/play-redis/tree/2.5.0)

Added `expiresIn(key: String): Option[Duration]` implementing PTTL
Added `expiresIn(key: String): Option[Duration]` implementing PTTL
command to get expiration of the given key. [#204](https://github.com/KarelCemus/play-redis/pull/204)

Introduced asynchronous implementation of advanced Java API for redis cache. The API
wraps the Scala version thus provides slightly worse performance and deals with
the lack of `classTag` in Play's API design. **This API implementation is experimental
the lack of `classTag` in Play's API design. **This API implementation is experimental
and may change in future.** Feedback will be welcome. [#206](https://github.com/KarelCemus/play-redis/issues/206)

Added `getFields(fields: String*)` and `getFields(fields: Iterable[String])` into `RedisMap` API
Expand All @@ -55,7 +65,7 @@ Cross-compiled with Scala 2.13 [#211](https://github.com/KarelCemus/play-redis/i

Update to Play `2.7.0` [#202](https://github.com/KarelCemus/play-redis/pull/202)

Added `getAll[T: ClassTag](keys: Iterable[String]): Result[Seq[Option[T]]]` into `AbstractCacheApi`
Added `getAll[T: ClassTag](keys: Iterable[String]): Result[Seq[Option[T]]]` into `AbstractCacheApi`
in order to also accept collections aside vararg. [#194](https://github.com/KarelCemus/play-redis/pull/194)

Fixed `getOrElse` method in Synchronous API with non-empty cache prefix. [#196](https://github.com/KarelCemus/play-redis/pull/196)
Expand All @@ -71,7 +81,7 @@ Returned keys are automatically unprefixed. [#184](https://github.com/KarelCemus

Support of plain arrays in JavaRedis [#176](https://github.com/KarelCemus/play-redis/pull/176).

Connection timeout introduced in [#147](https://github.com/KarelCemus/play-redis/issues/147)
Connection timeout introduced in [#147](https://github.com/KarelCemus/play-redis/issues/147)
is now configurable and can be disabled [#174](https://github.com/KarelCemus/play-redis/pull/174).

Removed deprecations introduced in [2.0.0](https://github.com/KarelCemus/play-redis/tree/2.0.0)
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ as well as on your premise.

- [synchronous and asynchronous APIs](#provided-apis)
- [implements standard APIs defined by Play's `cacheApi` project](#provided-apis)
- support of [named caches](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#named-caches)
- [works with Guice](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/40-migration.md#runtime-time-dependency-injection) as well as [compile-time DI](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/40-migration.md#compile-time-dependency-injection)
- [getOrElse and getOrFuture operations](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-cacheapi) easing the use
- [wildcards in remove operation](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-cacheapi)
- support of collections: [sets](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-sets), [lists](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-lists), and [maps](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-maps)
- [increment and decrement operations](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md#use-of-cacheapi)
- [eager and lazy invocation policies](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#eager-and-lazy-invocation) waiting or not waiting for the result
- several [recovery policies](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#recovery-policy) and possibility of further customization
- support of [several configuration sources](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#running-in-different-environments)
- support of [named caches](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#named-caches)
- [works with Guice](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/40-migration.md#runtime-time-dependency-injection) as well as [compile-time DI](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/40-migration.md#compile-time-dependency-injection)
- [getOrElse and getOrFuture operations](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-cacheapi) easing the use
- [wildcards in remove operation](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-cacheapi)
- support of collections: [sets](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-sets), [lists](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-lists), and [maps](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-maps)
- [increment and decrement operations](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md#use-of-cacheapi)
- [eager and lazy invocation policies](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#eager-and-lazy-invocation) waiting or not waiting for the result
- several [recovery policies](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#recovery-policy) and possibility of further customization
- support of [several configuration sources](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#running-in-different-environments)
- static in the configuration file
- from the connection string optionally in the environmental variable
- custom implementation of the configuration provider
- support of [standalone, cluster,](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#standalone-vs-cluster)
[aws-cluster,](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#aws-cluster)
and [sentinel modes](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#sentinel)
- build on the top of Akka actors and serializers, [agnostic to the serialization mechanism](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md#limitation-of-data-serialization)
- support of [standalone, cluster,](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#standalone-vs-cluster)
[aws-cluster,](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#aws-cluster)
and [sentinel modes](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#sentinel)
- build on the top of Akka actors and serializers, [agnostic to the serialization mechanism](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md#limitation-of-data-serialization)
- for simplicity, it uses deprecated Java serialization by default
- it is recommended to use [Kryo library](https://github.com/romix/akka-kryo-serialization) or any other mechanism

Expand Down Expand Up @@ -92,11 +92,11 @@ or you can use shortcuts in the table below.

To use this module:

1. [Add this library into your project](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/10-integration.md) and expose APIs
1. See the [configuration options](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/20-configuration.md)
1. [Browse examples of use](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/30-how-to-use.md)
1. [Add this library into your project](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/10-integration.md) and expose APIs
1. See the [configuration options](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/20-configuration.md)
1. [Browse examples of use](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/30-how-to-use.md)

If you come from older version, you might check the [Migration Guide](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/doc/40-migration.md)
If you come from older version, you might check the [Migration Guide](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/doc/40-migration.md)


## Samples
Expand Down Expand Up @@ -124,15 +124,15 @@ To your SBT `build.sbt` add the following lines:
// enable Play cache API (based on your Play version)
libraryDependencies += play.sbt.PlayImport.cacheApi
// include play-redis library
libraryDependencies += "com.github.karelcemus" %% "play-redis" % "3.0.0-M1"
libraryDependencies += "com.github.karelcemus" %% "play-redis" % "3.0.0-M3"
```


## Compatibility matrix

| play framework | play-redis | documentation |
|----------------|---------------------------------:|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| 2.9.x | <!-- Play 2.9 -->3.0.0-M1<!-- / --> | [see here](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/README.md) |
| 2.9.x | <!-- Play 2.9 -->3.0.0-M3<!-- / --> | [see here](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/README.md) |
| 2.8.x | <!-- Play 2.8 -->2.7.0<!-- / --> | [see here](https://github.com/KarelCemus/play-redis/blob/2.7.0/README.md) |
| 2.7.x | <!-- Play 2.7 -->2.5.1<!-- / --> | [see here](https://github.com/KarelCemus/play-redis/blob/2.5.1/README.md) |
| 2.6.x | <!-- Play 2.6 -->2.3.0<!-- / --> | [see here](https://github.com/KarelCemus/play-redis/blob/2.3.0/README.md) ([Migration Guide](https://github.com/KarelCemus/play-redis/blob/2.3.0/doc/40-migration.md)) |
Expand All @@ -150,7 +150,7 @@ like this library, please feel free to report it or contact me.
## Changelog

For the list of changes and migration guide please see
[the Changelog](https://github.com/KarelCemus/play-redis/blob/3.0.0-M1/CHANGELOG.md).
[the Changelog](https://github.com/KarelCemus/play-redis/blob/3.0.0-M3/CHANGELOG.md).


## Caveat
Expand Down
Loading

0 comments on commit dd96717

Please sign in to comment.