RingBuffer implements RingBufferMBean { public Slice get(byte[] key) { statsGets.recordEvent(); for (int i = 0; i < ringBuffers.length; i++) { int current = currentBuffer - i; if (current < 0) current = ringBuffers.length + current; Slice slice = ringBuffers[current].get(key); if (slice != null) { return slice; } } statsMisses.recordEvent(); return null; } private  RingBuffer(Buffer[] ringBuffers); static RingBuffer create(int amountBuffers, int bufferCapacity); Slice get(byte[] key); void put(byte[] key, byte[] data); void put(byte[] key, byte[] data, int offset, int length); @Override void reset(); @Override String getStatsPuts(); @Override double getStatsPutsRate(); @Override long getStatsPutsTotal(); @Override String getStatsGets(); @Override double getStatsGetsRate(); @Override long getStatsGetsTotal(); @Override String getStatsMisses(); @Override double getStatsMissesRate(); @Override long getStatsMissesTotal(); @Override int getItems(); @Override long getSize(); @Override String getLifetime(); @Override long getLifetimeSeconds(); @Override String getCurrentBuffer(); @Override int getFullCycles();  }
@Test public void testGet() { int amountBuffers = 10; int bufferCapacity = 100; RingBuffer ringBuffer = RingBuffer.create(amountBuffers, bufferCapacity); byte[] item = new byte[bufferCapacity]; fillBufferFully(ringBuffer, item, amountBuffers); for (int i = 0; i < amountBuffers; i++) { byte[] key = new byte[i]; Slice byteBuf = ringBuffer.get(key); byte[] array = byteBuf != null ? byteBuf.array() : null; if (array == null) { fail(); } assertEquals(array.length, item.length); } }