Esempio n. 1
0
File: io.go Progetto: cyx/busl
func NoContent(rd io.Reader, offset int64) bool {
	if !ReaderDone(rd) {
		return false
	}

	conn := redisPool.Get()
	defer conn.Close()

	strlen, err := redis.Int64(conn.Do("STRLEN", rd.(*reader).channel.id()))
	if err != nil {
		return false
	}

	return offset > (strlen - 1)
}
Esempio n. 2
0
File: io.go Progetto: cyx/busl
func (r *reader) fetch(length int) ([]byte, error) {
	conn := redisPool.Get()
	defer conn.Close()

	start, end := r.offset, r.offset+int64(length)

	conn.Send("MULTI")
	conn.Send("GETRANGE", r.channel.id(), start, end-1)
	conn.Send("STRLEN", r.channel.id())
	conn.Send("EXISTS", r.channel.doneId())
	conn.Send("EXPIRE", r.channel.id(), redisChannelExpire)

	list, err := redis.Values(conn.Do("EXEC"))
	data, err := redis.Bytes(list[0], err)
	size, err := redis.Int64(list[1], err)
	done, err := redis.Bool(list[2], err)

	if r.buffered = end < size; !r.buffered && done {
		err = io.EOF
	}

	return data, err
}