Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove Redis cache implementation leftovers (DEV-1503) #2290

Merged
merged 6 commits into from Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions docker-compose.yml
Expand Up @@ -69,8 +69,6 @@ services:
- KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME=admin
- KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD=test
- KNORA_WEBAPI_CACHE_SERVICE_ENABLED=true
- KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST=redis
- KNORA_WEBAPI_CACHE_SERVICE_REDIS_PORT=6379
- KNORA_WEBAPI_ALLOW_RELOAD_OVER_HTTP=true
- KNORA_WEBAPI_KNORA_API_EXTERNAL_HOST=0.0.0.0
- KNORA_WEBAPI_KNORA_API_EXTERNAL_PORT=3333
Expand Down
2 changes: 0 additions & 2 deletions docs/04-publishing-deployment/configuration.md
Expand Up @@ -57,8 +57,6 @@ A number of core settings is additionally configurable through system environmen
| app.triplestore.fuseki.username | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME | admin |
| app.triplestore.fuseki.password | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PASSWORD | test |
| app.cache-service.enabled | KNORA_WEBAPI_CACHE_SERVICE_ENABLED | true |
| app.cache-service.redis.host | KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST | localhost |
| app.cache-service.redis.port | KNORA_WEBAPI_CACHE_SERVICE_REDIS_PORT | 6379 |

## Selectively Disabling Routes

Expand Down
6 changes: 3 additions & 3 deletions docs/05-internals/development/building-and-running.md
Expand Up @@ -18,7 +18,7 @@ With [Docker](https://www.docker.com/) installed,

to create the knora-test repository and initialize it with loading some test data into the triplestore (Fuseki).

1. Start the entire knora-stack (fuseki (db), sipi, redis, api, salsah1) with the following command:
1. Start the entire knora-stack (fuseki (db), sipi, api, salsah1) with the following command:

```
$ make stack-up
Expand Down Expand Up @@ -89,8 +89,8 @@ database container can be printed out using the following command:
```
$ make stack-logs-db
```
Similarly, the logs of the other containers can be printed out by running make with `stack-logs-api`, `stack-logs-sipi`,
or `stack-logs-redis`. These commands print out and follow the logs, to only print the logs out without following, use
Similarly, the logs of the other containers can be printed out by running make with `stack-logs-api` or `stack-logs-sipi`.
These commands print out and follow the logs, to only print the logs out without following, use
`-no-follow` version of the commands for example:

```
Expand Down
Expand Up @@ -14,20 +14,13 @@ client code without the need for a running Knora instance.

Client test data is generated as a side effect of running E2E tests.
E2E tests use `ClientTestDataCollector` to collect API requests and
responses. The implementation of `ClientTestDataCollector` collects these
in a Redis hash. When the E2E tests have completed, the script
responses. When the E2E tests have completed, the script
`webapi/scripts/dump-client-test-data.sh` saves the collected test data
in a Zip file. It then checks the filenames in the Zip file by comparing them
with the list in `webapi/scripts/expected-client-test-data.txt`.

## Usage

On macOS, you will need to install Redis in order to have the `redis-cli` command-line tool:

```
brew install redis
```

To generate client test data, type:

```
Expand Down
13 changes: 0 additions & 13 deletions docs/05-internals/development/overview.md
Expand Up @@ -89,16 +89,3 @@ $ docker run --name sipi \
daschswiss/sipi \
/sipi/local/bin/sipi -config /localdir/sipi.test-config.lua
```

## Redis Server

The DSP-API server uses Redis for caching.

On macOS you can install Redis through [Homebrew](https://brew.sh):

```bash
$ brew install redis
```

If you don't want to use Redis, you can disable caching in `application.conf`
via the `app.use-redis-cache` key, by setting it to `false`.
2 changes: 0 additions & 2 deletions project/Dependencies.scala
Expand Up @@ -83,7 +83,6 @@ object Dependencies {

// caching
val ehcache = "net.sf.ehcache" % "ehcache" % "2.10.9.2"
val jedis = "redis.clients" % "jedis" % "4.3.1"

// serialization
val chill = "com.twitter" %% "chill" % "0.10.0" // Scala 3 incompatible
Expand Down Expand Up @@ -145,7 +144,6 @@ object Dependencies {
icu4j,
jacksonDatabind,
jakartaJSON,
jedis,
jenaText,
jodd,
jwtSprayJson,
Expand Down
2 changes: 1 addition & 1 deletion webapi/scripts/zap-client-test-data.sh
Expand Up @@ -4,7 +4,7 @@

set -e

# The name of the Zip file that contains client test data download from Redis.
# The name of the Zip file that contains client test data download from cache.
zip_file_name=client-test-data.zip

# Remove any existing client test data Zip file.
Expand Down
2 changes: 1 addition & 1 deletion webapi/scripts/zip-client-test-data.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Downloads client test data from Redis into a Zip file.
# Downloads client test data from cache into a Zip file.

# A pushd that produces no output.
pushd () {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions webapi/src/main/resources/application.conf
Expand Up @@ -485,16 +485,8 @@ app {
}

cache-service {

enabled = true
enabled = ${?KNORA_WEBAPI_CACHE_SERVICE_ENABLED}

redis {
host = "localhost"
host = ${?KNORA_WEBAPI_CACHE_SERVICE_REDIS_HOST}
port = 6379
port = ${?KNORA_WEBAPI_CACHE_SERVICE_REDIS_PORT}
}
}

client-test-data-service {
Expand Down
Expand Up @@ -224,13 +224,7 @@ final case class Shacl(
}

final case class CacheService(
enabled: Boolean,
redis: Redis
)

final case class Redis(
host: String,
port: Int
enabled: Boolean
)

final case class ClientTestDataService(
Expand Down
Expand Up @@ -56,7 +56,7 @@ trait InstrumentationSupport {

/**
* Based on the current class name, create a logger with the name in the
* form 'M-ClassName', e.g., 'M-RedisManager'.
* form 'M-ClassName', e.g., 'M-CacheManager'.
* All loggers returned by this method can be configured in 'logback.xml',
* i.e., turned on or off.
*/
Expand Down
Expand Up @@ -84,7 +84,7 @@ class StoresResponderADM(responderData: ResponderData) extends Responder(respond
_ = log.debug(s"resetTriplestoreContent - load ontology done - {}", loadOntologiesResponse.toString)

_ <- appActor.ask(CacheServiceFlushDB(systemUser))
_ = log.debug(s"resetTriplestoreContent - flushing Redis store done.")
_ = log.debug(s"resetTriplestoreContent - flushing cache store done.")

result = ResetTriplestoreContentResponseADM(message = "success")

Expand Down
Expand Up @@ -2197,7 +2197,7 @@ class UsersResponderADM(responderData: ResponderData)
private def invalidateCachedUserADM(maybeUser: Option[UserADM]): Future[Unit] =
if (responderData.cacheServiceSettings.cacheServiceEnabled) {
val keys: Set[String] = Seq(maybeUser.map(_.id), maybeUser.map(_.email), maybeUser.map(_.username)).flatten.toSet
// only send to Redis if keys are not empty
// only send to cache if keys are not empty
if (keys.nonEmpty) {
val result = appActor.ask(CacheServiceRemoveValues(keys))
result.map { res =>
Expand Down
Expand Up @@ -113,9 +113,4 @@ package object settings {
val IIIFManagerActorPath: String = StoreManagerActorPath + "/" + IIIFManagerActorName

val SipiConnectorActorName: String = "sipiConnector"

/* Cache */
val CacheServiceManagerActorName: String = "redisManager"
val CacheServiceManagerActorPath: String = StoreManagerActorPath + "/" + CacheServiceManagerActorName

}
Expand Up @@ -5,6 +5,4 @@

package org.knora.webapi.store.cache.config

final case class CacheServiceConfig(enabled: Boolean, redis: RedisConfig)

final case class RedisConfig(server: String, port: Int)
final case class CacheServiceConfig(enabled: Boolean)