Working with semaphore in Cache