UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'b6Dvhl9j8zodEckltrO6vrqQrk6bOixqwnI6kRdg4Mk='
WHERE
key_id = 'f40e7589e82a2b2f7a3f44f1c61d1575f008e3fddaeb3c32fd72b1a1b3743f75'
AND (
token = 'b6Dvhl9j8zodEckltrO6vrqQrk6bOixqwnI6kRdg4Mk='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)