<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def get_transcript(self, gene_pk, refseq_id):
        "Get a transcript from the cache or add a new record."
        if not refseq_id:
            return
        transcript_pk = self.transcripts.get(refseq_id)
        if transcript_pk:
            return transcript_pk
        gene = Gene(pk=gene_pk)
        transcript = Transcript(refseq_id=refseq_id, gene=gene)
        try:
            transcript.save()
        except IntegrityError:
            transcript = Transcript.objects.get(refseq_id=refseq_id, gene=gene)
        self.transcripts[refseq_id] = transcript.pk
        return transcript.pk