How to update Custom Settings value using Apex in Salesforce?

We can query or we can use getInstance() to get the value and then we can use update keyword to update the Custom Settings value.

Sample Code:
Test__c obj = new Test__c(Name = 'Test');
insert obj;
Test__c t = Test__c.getInstance('Test');
t.Size__c = 908;
update t;

Here Test__c is a Custom Settings and Test is the name of the record.