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

网站设计制作过程拒绝使用模板建站;使用PHP+MYSQL原生开发可交付网站源代码;符合网站优化排名的后台管理系统;成都网站制作、成都网站建设收费合理;免费进行网站备案等企业网站建设一条龙服务.我们是一家持续稳定运营了十余年的创新互联建站网站建设公司。
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