LSize returns the size of key in the bucket in the bucket at given bucket and key.
(bucket string, key []byte)
| 244 | |
| 245 | // LSize returns the size of key in the bucket in the bucket at given bucket and key. |
| 246 | func (tx *Tx) LSize(bucket string, key []byte) (int, error) { |
| 247 | if err := tx.checkTxIsClosed(); err != nil { |
| 248 | return 0, err |
| 249 | } |
| 250 | |
| 251 | b, err := tx.db.bucketMgr.GetBucket(DataStructureList, bucket) |
| 252 | if err != nil { |
| 253 | return 0, err |
| 254 | } |
| 255 | |
| 256 | var ( |
| 257 | bucketId = b.Id |
| 258 | l *data.List |
| 259 | exist bool |
| 260 | ) |
| 261 | |
| 262 | if l, exist = tx.db.Index.List.exist(bucketId); !exist { |
| 263 | return 0, ErrBucket |
| 264 | } |
| 265 | if tx.CheckExpire(bucket, key) { |
| 266 | return 0, ErrListNotFound |
| 267 | } |
| 268 | return l.Size(string(key)) |
| 269 | } |
| 270 | |
| 271 | // LRange returns the specified elements of the list stored in the bucket at given bucket,key, start and end. |
| 272 | // The offsets start and stop are zero-based indexes 0 being the first element of the list (the head of the list), |