Documentation
¶
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Delete(ctx context.Context, key string) (bool, error)
- func (c *Client) Get(ctx context.Context, key string) ([]byte, bool, error)
- func (c *Client) NodeForKey(key string) (string, error)
- func (c *Client) Nodes() []string
- func (c *Client) Ping(ctx context.Context, nodeID string) (*pb.PingResponse, error)
- func (c *Client) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
- type L1Cache
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the cache client SDK. It understands the hash ring and routes requests directly to the correct node.
func NewClient ¶
NewClient creates a new cache client. nodes is a map of nodeID → gRPC address (e.g., "node-1" → "localhost:7001").
func (*Client) NodeForKey ¶
NodeForKey returns the node ID that owns a given key (for debugging).
type L1Cache ¶
type L1Cache struct {
// contains filtered or unexported fields
}
L1Cache is a simple thread-safe LRU cache with TTL support for client-side hot key caching.
func NewL1Cache ¶
NewL1Cache creates a new L1 cache with the specified capacity and default TTL.
type Option ¶
type Option func(*Client)
Option is a functional option for configuring the Client.
func WithDialTimeout ¶
WithDialTimeout sets the gRPC dial timeout.
func WithL1Cache ¶
WithL1Cache enables the client-side L1 cache for hot keys.
func WithRequestTimeout ¶
WithRequestTimeout sets the default request timeout.