UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'cJyq26s32O80p3647uGLBKgahVQmAQ5QXbGKkfmRXG4=' 
WHERE 
  key_id = '31de84510189359fb78af95dc37509edd33c50537d68f69e98df8475ad1734d6' 
  AND (
    token = 'cJyq26s32O80p3647uGLBKgahVQmAQ5QXbGKkfmRXG4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027