sqlite

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 はSQLiteを使ったキーバリューストアの実装。 外部サービス不要で動作する。

func NewClient

func NewClient(ctx context.Context, path string) (*Client, error)

NewClient は指定されたファイルパスにSQLiteデータベースを開き、Clientを返す。 path に ":memory:" を指定するとインメモリDBとして動作する。

func (*Client) Close

func (c *Client) Close() error

Close はデータベース接続を閉じる。

func (*Client) Del

func (c *Client) Del(ctx context.Context, key string) (rErr error)

Del はキーを削除する。

func (*Client) DeleteExpired

func (c *Client) DeleteExpired(ctx context.Context) error

DeleteExpired は期限切れのレコードをすべて削除する。

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (_ string, rErr error)

Get はキーに対応する値を返す。キーが存在しないか期限切れの場合はエラーを返す。

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, value any, expiration time.Duration) (rErr error)

Set はキーに値をTTL付きで保存する。

func (*Client) StartCleanup

func (c *Client) StartCleanup(ctx context.Context, interval time.Duration)

StartCleanup は定期的に期限切れレコードを削除するゴルーチンを起動する。 ctxがキャンセルされると停止する。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL