Categories: GoFrame 教程

GoFrame 缓存管理-接口化设计

缓存组件采用了接口化设计,提供了​Adapter​接口,任何实现了​Adapter​接口的对象均可注册到缓存管理对象中,使得开发者可以对缓存管理对象进行灵活的自定义实现和扩展。

接口定义

Adapter​接口定义如下:

https://pkg.go.dev/github.com/gogf/gf/v2/os/gcache#Adapter

注册接口实现

通过该方法将实现的​adapter​应用到对应的​Cache​对象上:

// SetAdapter changes the adapter for this cache.
// Be very note that, this setting function is not concurrent-safe, which means you should not call
// this setting function concurrently in multiple goroutines.
func (c *Cache) SetAdapter(adapter Adapter)

获取接口实现

通过该方法获取当前注册的​adapter​接口实现对象上:

// GetAdapter returns the adapter that is set in current Cache.
func (c *Cache) GetAdapter() Adapter

唐伯虎点蚊香

前端小白,想各位学习!

Share
Published by
唐伯虎点蚊香

Recent Posts

聊聊vue3中的defineProps

在Vue 3中,defineP…

1 周 ago

在 Chrome 中删除、允许和管理 Cookie

您可以选择删除现有 Cooki…

2 周 ago

自定义指令:聊聊vue中的自定义指令应用法则

今天我们来聊聊vue中的自定义…

3 周 ago

聊聊Vue中@click.stop和@click.prevent

一起来学下聊聊Vue中@cli…

4 周 ago

Nginx 基本操作:启动、停止、重启命令。

我们来学习Nginx基础操作:…

1 月 ago

Vue3:手动清理keep-alive组件缓存的方法

Vue3中手动清理keep-a…

1 月 ago