example

package
v0.0.8-20250724 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

cache包使用示例 展示如何使用统一的工厂函数创建不同类型的缓存实例

本文件提供了完整的缓存使用示例,包括Redis、BadgerDB和BuntDB三种实现 通过实际代码演示统一接口的优势和使用方法

示例内容: - 基本键值操作:Set/Get/Delete/Exists/Expire - 队列操作:Push/Pop/LPush/RPush/LPop/RPop/PopAll/Len - 哈希表操作:HSet/HGet/HDel/HGetAll - 事务操作:BeginTx/Commit/Rollback - 驱动发现:列出所有可用驱动

演示特点: - 统一的API调用方式 - 相同的业务逻辑代码 - 灵活的驱动切换 - 完整的错误处理

运行方式:

go run example.go
或在测试中调用各个Example函数

作者: gophertool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExampleBadgerUsage

func ExampleBadgerUsage()

ExampleBadgerUsage BadgerDB缓存使用示例

func ExampleBuntUsage

func ExampleBuntUsage()

ExampleBuntUsage BuntDB缓存使用示例

func ExampleRedisUsage

func ExampleRedisUsage()

ExampleRedisUsage Redis缓存使用示例

func ExampleTransactionUsage

func ExampleTransactionUsage()

ExampleTransactionUsage 演示事务操作

func ListAvailableDrivers

func ListAvailableDrivers()

ListAvailableDrivers 列出所有可用的缓存驱动

Types

This section is empty.

Jump to

Keyboard shortcuts

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