~nickbp/kapiti

a8d53481eaf10a685fbb4a4e98c49b13dfbc95ff — Nick Parker 2 years ago 871b3a5
Initialize scratch buffer size, not just capacity
1 files changed, 4 insertions(+), 1 deletions(-)

M src/cache/redis.rs
M src/cache/redis.rs => src/cache/redis.rs +4 -1
@@ 43,11 43,14 @@ impl Cache {
            redis_conn.set_write_timeout(Some(timeout))?;
            redis_conn.set_read_timeout(Some(timeout))?;
        }
        // Scratch wants buffer to already have some size (not just capacity)
        let mut scratch_buf = BytesMut::with_capacity(1024);
        scratch_buf.resize(scratch_buf.capacity(), 0);
        Ok(Cache {
            redis_conn,
            // Set up a reasonable allocation - will expand automatically if needed.
            store_buf: BytesMut::with_capacity(1024),
            scratch_buf: BytesMut::with_capacity(1024),
            scratch_buf,
        })
    }