public void addAndTrimUptoMaxSize(ComplexEventChunk<StreamEvent> addingEventChunk) {
        ComplexEventChunk<StreamEvent> addingEventChunkForCache = new ComplexEventChunk<>();
        addingEventChunk.reset();
        while (addingEventChunk.hasNext()) {
            StreamEvent event = addingEventChunk.next();
            addingEventChunkForCache.add((StreamEvent) generateEventWithRequiredFields(event, siddhiAppContext,
                    cacheExpiryEnabled));
        }
        readWriteLock.writeLock().lock();
        try {
            super.add(addingEventChunkForCache);
            if (this.size() > maxSize) {
                this.deleteEntriesUsingCachePolicy(this.size() - maxSize);
            }
        } finally {
            readWriteLock.writeLock().unlock();
        }
    }
common interface for FIFO, LRU, and LFU cache tables
modules/siddhi-core/src/main/java/io/siddhi/core/table/CacheTable.java