-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.go
More file actions
31 lines (24 loc) · 1013 Bytes
/
queue.go
File metadata and controls
31 lines (24 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cache
import "github.com/go-universal/cast"
// Queue represents a thread-safe, nil-safe queue interface.
// It provides methods to perform common queue operations.
type Queue interface {
// Push adds a value to the end of the queue.
// Returns an error if the operation fails.
Push(value any) error
// Pull retrieves and removes the first item from the queue.
// Returns the value and an error if the operation fails.
Pull() (any, error)
// Pop retrieves and removes the last item from the queue.
// Returns the value and an error if the operation fails.
Pop() (any, error)
// Cast retrieves and removes the first item from the queue,
// casting it to a `cast.Caster` type.
// Returns the `Caster` instance and an error if the operation fails.
Cast() (cast.Caster, error)
// Length returns the current number of items in the queue.
// Returns the queue length and an error if the operation fails.
Length() (int64, error)
// Clear removes all items from the queue.
Clear() error
}