@Override
    public <T> ISignalWriteStream putBinary(final String cacheKey, final T jsonObject, final long timeToLive)
            throws IOException {
        final CacheEntry entry = new CacheEntry();
        entry.setExpiresOn(System.currentTimeMillis() + (timeToLive * 1000));
        entry.setHead(JSON_MAPPER.writeValueAsString(jsonObject));
        final IApimanBuffer data = bufferFactory.createBuffer();
        return new ISignalWriteStream() {
            boolean finished = false;
            boolean aborted = false;

            @Override
            public void abort(Throwable t) {
                finished = true;
                aborted = false;
            }

            @Override
            public boolean isFinished() {
                return finished;
            }

            @Override
            public void write(IApimanBuffer chunk) {
                data.append(chunk);
            }

            @Override
            public void end() {
                if (!aborted) {
                    entry.setData(Base64.encodeBase64String(data.getBytes()));
                    try {
                        IndexRequest indexRequest = new IndexRequest(getFullIndexName()).source(JSON_MAPPER.writeValueAsBytes(entry), XContentType.JSON).id(cacheKey);
                        getClient().index(indexRequest, RequestOptions.DEFAULT);
                    } catch (Throwable e) {
                        LOGGER.error(e, "Unable to put binary at {0}. This should be non-fatal.", cacheKey);
                    }
                }
                finished = true;
            }
        };
    }
@see io.apiman.gateway.engine.components.ICacheStoreComponent#putBinary(java.lang.String, java.lang.Object, long)
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/EsCacheStoreComponent.java