Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 11-28-2023 02:42 AM
Just trying to use a simple Groovy Script for setting TTL on redis keys with a given pattern.
@Grab(group='org.springframework.data', module='spring-data-redis', version='2.6.2')
import org.springframework.data.redis.connection.RedisConnection
import org.springframework.data.redis.core.ScanOptions
def pool = CTL.redis.getConnection()
pool.withCloseable {conn->
def keyPattern = 'raw:extra:*'
def scanOptions = ScanOptions.scanOptions().match(keyPattern).build()
def cursor = conn.keyCommands().scan(scanOptions)
while(cursor.hasNext()) {
def key = cursor.next()
// Check if the key has a TTL
if(conn.keyCommands().pTtl(key) == -1) {
// Set a 15 days TTL for the key
conn.keyCommands().expire(key, 15 * 24 * 60 * 60)
}
}
}
However this is giving this specific error. I tried using KeyScanOptions, without grabbing the spring-data-redis and a builder. Still getting the same error.
ExecuteGroovyScript[id=6f743677-05b0-1622-bb0b-cbb0e5127a50] groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy6940493.scan() is applicable for argument types: (org.springframework.data.redis.core.ScanOptions) values: [org.springframework.data.redis.core.ScanOptions@558a5d9a]
Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions), scan(org.springframework.data.redis.core.ScanOptions), any(), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)
The following classes appear as argument class and as parameter class, but are defined by different class loader:
org.springframework.data.redis.core.ScanOptions (defined by 'groovy.lang.GroovyClassLoader@2ddbb9b9' and 'org.apache.nifi.nar.NarClassLoader[./work/nar/extensions/nifi-redis-service-api-nar-1.16.0.nar-unpacked]')
If one of the method suggestions matches the method you wanted to call,
then check your class loader setup.: groovy.lang.MissingMethodException: No signature of method: com.sun.proxy.$Proxy6940493.scan() is applicable for argument types: (org.springframework.data.redis.core.ScanOptions) values: [org.springframework.data.redis.core.ScanOptions@558a5d9a]
Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions), scan(org.springframework.data.redis.core.ScanOptions), any(), each(groovy.lang.Closure), tap(groovy.lang.Closure), any(groovy.lang.Closure)
The following classes appear as argument class and as parameter class, but are defined by different class loader:
org.springframework.data.redis.core.ScanOptions (defined by 'groovy.lang.GroovyClassLoader@2ddbb9b9' and 'org.apache.nifi.nar.NarClassLoader[./work/nar/extensions/nifi-redis-service-api-nar-1.16.0.nar-unpacked]')
If one of the method suggestions matches the method you wanted to call,
then check your class loader setup.
I checked the folder and it has spring-data-redis:2.6.2 under this one. I also tried using keys for key lookup and it works but I don't want to use keys for performance reasons. Other functions are working fine but just ScanOptions is giving this specific error.
Created 11-28-2023 09:40 AM
Did you try what the error says?
Possible solutions: scan(org.springframework.data.redis.core.KeyScanOptions)
Created 11-30-2023 12:26 AM
yea I tried using KeyScanOptions as well but the same error