Documentation
¶
Index ¶
- type GraphCache
- func (c *GraphCache[S, T]) AddEdge(tail, head S, w float32)
- func (c *GraphCache[S, T]) AddEdgeWithExpiration(tail, head S, w float32, expiration time.Time)
- func (c *GraphCache[S, T]) AddEdgeWithTTL(tail, head S, w float32, ttl time.Duration)
- func (c *GraphCache[S, T]) AddVertexWithExpiration(key S, value T, expiration time.Time)
- func (c *GraphCache[S, T]) AddVertexWithTTL(key S, value T, ttl time.Duration)
- func (c *GraphCache[S, T]) DeleteEdge(tail, head S)
- func (c *GraphCache[S, T]) DeleteVertex(key S)
- func (c *GraphCache[S, T]) GetEdgeDetail(tail, head S) (float32, time.Time, bool)
- func (c *GraphCache[S, T]) GetVertex(key S) (T, bool)
- func (c *GraphCache[S, T]) GetWeight(tail, head S) (float32, bool)
- func (c *GraphCache[S, T]) Neighbor(seed S, step int, k int, tfidf bool) *graph.Graph[S, T]
- func (c *GraphCache[S, T]) PutEdgeWithExpiration(tail, head S, w float32, expiration time.Time)
- func (c *GraphCache[S, T]) PutVertex(key S, value T)
- func (c *GraphCache[S, T]) Watch(ctx context.Context, interval time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GraphCache ¶
type GraphCache[S comparable, T any] struct { // contains filtered or unexported fields }
func NewGraphCache ¶
func NewGraphCache[S comparable, T any](defaultTTL time.Duration) *GraphCache[S, T]
func (*GraphCache[S, T]) AddEdge ¶
func (c *GraphCache[S, T]) AddEdge(tail, head S, w float32)
func (*GraphCache[S, T]) AddEdgeWithExpiration ¶
func (c *GraphCache[S, T]) AddEdgeWithExpiration(tail, head S, w float32, expiration time.Time)
func (*GraphCache[S, T]) AddEdgeWithTTL ¶
func (c *GraphCache[S, T]) AddEdgeWithTTL(tail, head S, w float32, ttl time.Duration)
func (*GraphCache[S, T]) AddVertexWithExpiration ¶
func (c *GraphCache[S, T]) AddVertexWithExpiration(key S, value T, expiration time.Time)
func (*GraphCache[S, T]) AddVertexWithTTL ¶
func (c *GraphCache[S, T]) AddVertexWithTTL(key S, value T, ttl time.Duration)
func (*GraphCache[S, T]) DeleteEdge ¶
func (c *GraphCache[S, T]) DeleteEdge(tail, head S)
func (*GraphCache[S, T]) DeleteVertex ¶
func (c *GraphCache[S, T]) DeleteVertex(key S)
func (*GraphCache[S, T]) GetEdgeDetail ¶
func (c *GraphCache[S, T]) GetEdgeDetail(tail, head S) (float32, time.Time, bool)
GetEdgeDetail returns the current edge weight together with the latest contribution expiration. The expiration is the moment after which the edge is guaranteed to have decayed to zero. When no edge exists, ok is false.
func (*GraphCache[S, T]) GetVertex ¶
func (c *GraphCache[S, T]) GetVertex(key S) (T, bool)
func (*GraphCache[S, T]) GetWeight ¶
func (c *GraphCache[S, T]) GetWeight(tail, head S) (float32, bool)
func (*GraphCache[S, T]) PutEdgeWithExpiration ¶ added in v0.5.1
func (c *GraphCache[S, T]) PutEdgeWithExpiration(tail, head S, w float32, expiration time.Time)
PutEdgeWithExpiration atomically replaces the (tail, head) edge weight. AddEdgeWithExpiration is additive (Add semantics) so a naive "DeleteEdge + AddEdgeWithExpiration" sequence performed by callers exposes a window in which concurrent GetEdge readers observe a spurious NotFound. PutEdgeWithExpiration takes the write lock once and performs the delete + add under the same lock, restoring atomicity for the idempotent Put semantics.
func (*GraphCache[S, T]) PutVertex ¶
func (c *GraphCache[S, T]) PutVertex(key S, value T)