UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'd88A0RvUrtTwU8FC8HFHIVwEGHEWpVlH+SDrGuXys+k='
WHERE
key_id = 'b223f46c5035eec583ab38e60ad5d7fb8cad12062b70a178d327be38c209fa12'
AND (
token = 'd88A0RvUrtTwU8FC8HFHIVwEGHEWpVlH+SDrGuXys+k='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)