What happen if I try to use SetObject and I already had the same key? - cachingframework.redis

I'm working on a project using Redis cache with cachingFramework.redis.
I already have working the get function with Redis (using FetchObject)
but I need to update the Save function to save in DB and override/update the key/value in Redis.
Should I use SetObject? or I need to call first Remove(key)

It really depends on the when parameter, but by default the SET operation on redis overrides the current value, regardless of its type. Here is the documentation.
So you don't need to call the Remove method.
You can check here how StackExchange.Redis library choose between different SET commands (SET, SETNX, SETEX) depending on the parameters.

Related

GRPC: How to set/modify a field after it has already been built

Say I return from a function called external() something like
return hotelRoomReservation.newBuilder()
.setCheckInTime(user.checkInTime)
.setCheckOutTime(user.checkOutTime)
.build()
and set it to a variable called reservation. Then, at a later time, say in the calling function, I want to edit one of the fields. What I would like to do is:
reservation.updateCheckInTime(newCheckInTime)
How can I achieve this after the GRPC message has already been built?
You will have to convert the message back to a builder (toBuilder()), add the update, build it again, and overwrite the variable holding the message. This isn't really different from e.g. a String, where you can't modify a character in the string, but you could convert to a StringBuilder, make some changes, and build it into a string again.
(This is assuming you're not using the Kotlin proto bindings, in which case you can use .copy and don't need a builder, though you still need to change the variable.)

Redis RESP3 protocol -- how to set it for luascript?

I am using Redis 7.0.4. I am trying to use RESP3 protocol so that the luascript responses are making more sense. When I use the hello command in luascript, it throws error
This Redis command is not allowed from script
If I set it from command line, it seems to be temporary and fallback to 2.
What is the right way to set it, so my script can take advantage of it?
HELLO is not allowed in Lua script. If you want to switch RESP version in Lua script, you should call redis.setresp(version) instead.
-- use RESP3
redis.setresp(3)
Also, RESP3 support some new types, so you need to be careful with the RESP3 data type conversion from/to Lua types. Check this for detail.

Is there a way to add a parameter during run-time?

At the Manual Judgement stage we were hoping we could enter a value, continue and pass that value onto Jenkins with "${#judgment("Manual Judgment")}". We can pass the predefined option but can't enter a new one. Is there a way of getting this to work or an alternative method?
One way to achieve this is by using pipeline parameters.
In configuration stage of the pipeline, add a parameter (say Name="jenkins") and configure the parameter's options (like default value, required or not)
Before the manual judgment step, create a Evaluate Variables stage. In the stage configuration, create a variable named "jenkins" with the value ${parameters.jenkins}
In manual judgment's options, add the variable ${jenkins}
Now, during the manual judgment stage, it would show an option with the value provided to the pipeline.
You could also join Spinnaker's slack here: https://join.spinnaker.io/

In jsr352 batch job xml, how to read/inject a environmental variable from system

I have environmental variable called ENV, which holds the DEV,QA OR PROD region as value. When the server.xml loaded it includes the corresponding db configuration using this variable. For ex: db-config-${env.GAH_ENV}.xml
I would like to pass the same value to the batch job xml as a job parameter or properties to any of the class. How Can I do that.
below code snippet not working
<property name="environment" value="${env.GAH_ENV}"/>
The short answer is that using a batch property may not be a good solution and you might consider something else like MicroProfile's #ConfigProperty.
The reason is there's not a built-in way to access environmental variables through JSL substitution. There is also not a convenient way for one artifact to set a property value to be used by a second artifact running later within the job execution.
In the special case that you are starting the job from within the same JVM it will execute, of course, you could pass the env var value as a job parameter.
But in the general case, if you can change the Java code and you don't really need a batch property I would use a MicroProfile Config property instead, injected via #Inject #ConfigProperty.
By doing so you lose the batch-specific substitution precedence, including the override available via job parameters passed with the submit/start. You also give up the ability to use this property in other JSL substitutions (to "compose" its value into other batch properties via other substitutions).
But you at least get a property with its own various levels of precedence/override (e.g. server config, env var, microprofile-config.properties), which is more flexible than just always reading the env var via System.getenv( ).
This is certainly an area to consider for the next version of the (now-Jakarta) Batch spec.

gtk3 get settings value from GtkSettings

I want to programmatically retrieve the value of the word wrap setting for GEdit3 from inside a Python plugin.
The GtkSettings class provides a method to set a string property, but how does one retrieve the value of a string property? I see no "getter" method.
I have also consulted pydoc gi.repository.Gtk.Settings - the methods listed there are the same as the online docs.
I am able to retrieve the property value of interest with the gsettings CLI utility. The command gsettings get org.gnome.gedit.preferences.editor wrap-mode
yields the value 'word'. I was hoping not to have to use subprocess.Popen() just to retrieve this property, however.
This will work
from gi.repository import Gio
a = Gio.Settings('org.gnome.gedit.preferences.editor')
a.get_string('wrap-mode')
Since you're using automatic generated bindings, C code samples will work just fine for you, it is just about changing the syntax.