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