You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cache.go
    path of file: ./repos/cadence/service/history/replication
    
    the code of the file until where you have to start completion: // The MIT License (MIT)
//
// Copyright (c) 2022 Uber Technologies Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software a
    
func (c *Cache) Put(task *types.ReplicationTask) error {
	c.mu.Lock()
	defer c.mu.Unlock()

	// Check for full cache
	if len(c.order) >= c.capacity() {
		return errCacheFull
	}

	taskID := task.SourceTaskID

	// Reject task as it was already acknowledged
	if c.lastAck >= taskID {
		return errAlreadyAcked
	}

	// Do not add duplicate tasks
	if _, exists := c.cache[taskID]; exists {
		return nil
	}

	c.cache[taskID] = task
	heap.Push(&c.order, taskID)

	return nil
}