empiredan commented on code in PR #2185:
URL:
https://github.com/apache/incubator-pegasus/pull/2185#discussion_r1929961401
##########
src/server/pegasus_write_service_impl.h:
##########
@@ -569,6 +663,83 @@ class pegasus_write_service::impl : public
dsn::replication::replica_base
return raw_key;
}
+ // Calculate expire timestamp in seconds for the keys not contained in the
storage
+ // according to `req`.
+ template <typename TRequest>
+ static inline int32_t calc_expire_on_non_existent(const TRequest &req)
+ {
+ return req.expire_ts_seconds > 0 ? req.expire_ts_seconds : 0;
+ }
+
+ // Calculate new expire timestamp in seconds for the keys contained in the
storage
+ // according to `req` and their current expire timestamp in `get_ctx`.
+ template <typename TRequest>
+ static inline int32_t calc_expire_on_existing(const TRequest &req,
+ const db_get_context
&get_ctx)
+ {
+ if (req.expire_ts_seconds == 0) {
+ // Still use current expire timestamp of the existing key as the
new value.
+ return static_cast<int32_t>(get_ctx.expire_ts);
+ }
+
+ if (req.expire_ts_seconds < 0) {
Review Comment:
Yes, `-1` means clearing TTL as is described by Java client `if ttlSeconds
== -1, then update to no ttl if increment succeed.` (see
https://github.com/apache/incubator-pegasus/blob/master/java-client/src/main/java/org/apache/pegasus/client/PegasusClientInterface.java#L561);
and Java client would throw exception once it is less than -1 (see
https://github.com/apache/incubator-pegasus/blob/master/java-client/src/main/java/org/apache/pegasus/client/PegasusTable.java#L733).
On server-side, currently non-idempotent `incr` would also clear TTL once it
is less than 0 (see
https://github.com/apache/incubator-pegasus/blob/master/src/server/pegasus_write_service_impl.h#L235).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]