golib/gcache/readme.adoc

29 lines
445 B
Plaintext
Raw Permalink Normal View History

2023-10-11 07:36:56 +08:00
= 说明
2023-06-15 21:22:51 +08:00
:author: tiglog
:experimental:
:toc: left
:toclevels: 3
:toc-title: 目录
:sectnums:
:icons: font
:!webfonts:
:autofit-option:
:source-highlighter: rouge
:rouge-style: github
:source-linenums-option:
2023-10-11 07:36:56 +08:00
:revdate: 2023-10-11
2023-06-15 21:22:51 +08:00
:imagesdir: ./img
2023-10-11 07:36:56 +08:00
== 快速使用
2023-06-15 21:22:51 +08:00
2023-10-11 07:36:56 +08:00
[source,go]
2023-06-15 21:22:51 +08:00
----
2023-10-11 07:36:56 +08:00
c := cache.NewMemCache()
c.Set("a", 1)
c.Set("b", 1, cache.WithEx(1*time.Second))
time.sleep(1*time.Second)
c.Get("a") // 1, true
c.Get("b") // nil, false
2023-06-15 21:22:51 +08:00
----