UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Rq+r5W+ARV1C4yzbWNcL8M/YBUagoemav99m6zpsaqI=' 
WHERE 
  key_id = '217686440075100e43190eaa80440720c29d39d29539f1e51b5dab70a04270d4' 
  AND (
    token = 'Rq+r5W+ARV1C4yzbWNcL8M/YBUagoemav99m6zpsaqI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032