UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'B9mZDHVItBCD5zpbWBgDguK+KLEmjqodxt1bNG/RRY0='
WHERE
key_id = 'e597f23e18579eba1ad028e8c880cbb81f66e73f3ff9d9f0a95fe700680d7b7c'
AND (
token = 'B9mZDHVItBCD5zpbWBgDguK+KLEmjqodxt1bNG/RRY0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)