Skip to content

Commit 3e23d29

Browse files
committed
v1.0.0
1 parent 5a6e6e8 commit 3e23d29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+239
-736
lines changed

.gitattributes

Lines changed: 0 additions & 15 deletions
This file was deleted.

FUTURE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
## ✒ 未来版本的新特性 (Features in future versions)
22

3+
### v1.0.0
4+
5+
* [x] 稳定的 API
6+
37
### v0.6.x
48

5-
* [ ] 梳理代码,优化代码风格,精简部分代码和注释
6-
* [ ] 完善监控上报器,提供更多缓存信息查询的方法
9+
* [x] 梳理代码,优化代码风格,精简部分代码和注释
710

811
### v0.5.x
912

HISTORY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## ✒ 历史版本的特性介绍 (Features in old versions)
22

3+
### v1.0.0
4+
5+
> 此版本发布于 2025-03-15
6+
7+
* 稳定的 API 版本
8+
* 调整快速时钟的代码,更改包名为 fastclock
9+
310
### v0.6.1
411

512
> 此版本发布于 2024-01-18

README.en.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
* Sentinel cleanup supports, cleaning up at fixed duration
2424
* Singleflight supports, which can decrease the times of cache penetration
2525
* Timer task supports, which is convenient to load data to cache
26-
* Report supports, providing several reporting points.
26+
* Report supports, providing several reporting points
27+
* Fast clock supports, fetching current time in nanoseconds
2728

2829
_Check [HISTORY.md](./HISTORY.md) and [FUTURE.md](./FUTURE.md) to get more information._
2930

@@ -143,11 +144,7 @@ BenchmarkGoCacheSet-12 4921483 249.0 ns/op
143144

144145
> Notice: Ecache only has lru mode, including v1 and v2; Freecache has 256 shardings, and we can't reset to 1.
145146
146-
> Benchmarks: [_examples/performance_test.go](./_examples/performance_test.go)
147-
148-
As you can see, cachego has a higher performance with sharding, but sharding has one-more-time positioning
149-
operation, so if the locking cost is less than the cost of positioning, this sharding is dragging. However, it has
150-
better performance in most time.
147+
> Benchmarks: [_examples/performance_test.go](./_examples/performance_test.go).
151148
152149
### 👥 Contributors
153150

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* 自带 singleflight 机制,减少缓存穿透的伤害
2424
* 自带定时任务封装,方便热数据定时加载到缓存
2525
* 支持上报缓存状况,可自定义多个缓存上报点
26+
* 自带快速时钟,支持纳秒级获取时间
2627

2728
_历史版本的特性请查看 [HISTORY.md](./HISTORY.md)。未来版本的新特性和计划请查看 [FUTURE.md](./FUTURE.md)_
2829

@@ -142,10 +143,7 @@ BenchmarkGoCacheSet-12 4921483 249.0 ns/op
142143

143144
> 注:Ecache 只有 LRU 模式,v1 和 v2 两个版本;Freecache 默认是 256 分片,无法调节为 1 个分片进行对比测试。
144145
145-
> 测试文件:[_examples/performance_test.go](./_examples/performance_test.go)
146-
147-
可以看出,使用分片机制后的读写性能非常高,但是分片会多一次哈希定位的操作,如果加锁的消耗小于定位的消耗,那分片就不占优势。
148-
不过在绝大多数的情况下,分片机制带来的性能提升都是巨大的,尤其是对写操作较多的 lru 和 lfu 实现。
146+
> 测试文件:[_examples/performance_test.go](./_examples/performance_test.go)
149147
150148
### 👥 贡献者
151149

_examples/basic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/clock.go renamed to _examples/fast_clock.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -20,21 +20,17 @@ import (
2020
"time"
2121

2222
"github.com/FishGoddess/cachego"
23-
"github.com/FishGoddess/cachego/pkg/clock"
23+
"github.com/FishGoddess/cachego/pkg/fastclock"
2424
)
2525

2626
func main() {
27-
// Create a fast clock and get current time in nanosecond by Now.
28-
c := clock.New()
29-
c.Now()
30-
3127
// Fast clock may return an "incorrect" time compared with time.Now.
3228
// The gap will be smaller than about 100 ms.
3329
for i := 0; i < 10; i++ {
3430
time.Sleep(time.Duration(rand.Int63n(int64(time.Second))))
3531

3632
timeNow := time.Now().UnixNano()
37-
clockNow := c.Now()
33+
clockNow := fastclock.NowNanos()
3834

3935
fmt.Println(timeNow)
4036
fmt.Println(clockNow)
@@ -43,8 +39,8 @@ func main() {
4339
}
4440

4541
// You can specify the fast clock to cache by WithNow.
46-
// All getting current time operations in this cache will use fast clock.
47-
cache := cachego.NewCache(cachego.WithNow(clock.New().Now))
42+
// All time used in this cache will be got from fast clock.
43+
cache := cachego.NewCache(cachego.WithNow(fastclock.NowNanos))
4844
cache.Set("key", 666, 100*time.Millisecond)
4945

5046
value, ok := cache.Get("key")

_examples/gc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/lfu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/lru.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/performance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/report.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/sharding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

_examples/ttl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cache_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cache_type_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 FishGoddess. All Rights Reserved.
1+
// Copyright 2025 FishGoddess. All Rights Reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)