Skip to content

Commit 8b39277

Browse files
committed
added policy directory
1 parent 67b9b3d commit 8b39277

21 files changed

+35
-35
lines changed

cache.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import (
44
"sync"
55
"time"
66

7-
"github.com/Code-Hex/go-generics-cache/clock"
8-
"github.com/Code-Hex/go-generics-cache/fifo"
9-
"github.com/Code-Hex/go-generics-cache/lfu"
10-
"github.com/Code-Hex/go-generics-cache/lru"
11-
"github.com/Code-Hex/go-generics-cache/mru"
12-
"github.com/Code-Hex/go-generics-cache/simple"
7+
"github.com/Code-Hex/go-generics-cache/policy/clock"
8+
"github.com/Code-Hex/go-generics-cache/policy/fifo"
9+
"github.com/Code-Hex/go-generics-cache/policy/lfu"
10+
"github.com/Code-Hex/go-generics-cache/policy/lru"
11+
"github.com/Code-Hex/go-generics-cache/policy/mru"
12+
"github.com/Code-Hex/go-generics-cache/policy/simple"
1313
)
1414

1515
// Interface is a common-cache interface.

example_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func ExampleCache() {
2020
// 0 false
2121
}
2222

23-
func ExampleCacheAsClock() {
23+
func ExampleAsClock() {
2424
// use clock cache algorithm.
2525
c := cache.New(cache.AsClock[string, int]())
2626
c.Set("a", 1)
@@ -33,7 +33,7 @@ func ExampleCacheAsClock() {
3333
// 0 false
3434
}
3535

36-
func ExampleCacheWithExpiration() {
36+
func ExampleWithExpiration() {
3737
c := cache.New(cache.AsFIFO[string, int]())
3838
exp := 250 * time.Millisecond
3939
c.Set("a", 1, cache.WithExpiration(exp))
@@ -58,7 +58,7 @@ func ExampleCacheWithExpiration() {
5858
// 0 false
5959
}
6060

61-
func ExampleDelete() {
61+
func ExampleCache_Delete() {
6262
c := cache.New(cache.AsMRU[string, int]())
6363
c.Set("a", 1)
6464
c.Delete("a")
@@ -68,7 +68,7 @@ func ExampleDelete() {
6868
// 0 false
6969
}
7070

71-
func ExampleKeys() {
71+
func ExampleCache_Keys() {
7272
c := cache.New(cache.AsLFU[string, int]())
7373
c.Set("a", 1)
7474
c.Set("b", 1)
@@ -78,7 +78,7 @@ func ExampleKeys() {
7878
// [a b c]
7979
}
8080

81-
func ExampleContains() {
81+
func ExampleCache_Contains() {
8282
c := cache.New(cache.AsLRU[string, int]())
8383
c.Set("a", 1)
8484
fmt.Println(c.Contains("a"))
@@ -88,7 +88,7 @@ func ExampleContains() {
8888
// false
8989
}
9090

91-
func ExampleNumberCache() {
91+
func ExampleNewNumber() {
9292
nc := cache.NewNumber[string, int]()
9393
nc.Set("a", 1)
9494
nc.Set("b", 2, cache.WithExpiration(time.Minute))
File renamed without changes.

clock/clock_test.go renamed to policy/clock/clock_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/Code-Hex/go-generics-cache/clock"
7+
"github.com/Code-Hex/go-generics-cache/policy/clock"
88
)
99

1010
func TestSet(t *testing.T) {

clock/example_test.go renamed to policy/clock/example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package clock_test
33
import (
44
"fmt"
55

6-
"github.com/Code-Hex/go-generics-cache/clock"
6+
"github.com/Code-Hex/go-generics-cache/policy/clock"
77
)
88

9-
func ExampleCache() {
9+
func ExampleNewCache() {
1010
c := clock.NewCache[string, int]()
1111
c.Set("a", 1)
1212
c.Set("b", 2)
@@ -33,7 +33,7 @@ func ExampleCache() {
3333
// 3
3434
}
3535

36-
func ExampleCacheKeys() {
36+
func ExampleCache_Keys() {
3737
c := clock.NewCache[string, int]()
3838
c.Set("foo", 1)
3939
c.Set("bar", 2)

fifo/example_test.go renamed to policy/fifo/example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package fifo_test
33
import (
44
"fmt"
55

6-
"github.com/Code-Hex/go-generics-cache/fifo"
6+
"github.com/Code-Hex/go-generics-cache/policy/fifo"
77
)
88

9-
func ExampleCache() {
9+
func ExampleNewCache() {
1010
c := fifo.NewCache[string, int]()
1111
c.Set("a", 1)
1212
c.Set("b", 2)
@@ -33,7 +33,7 @@ func ExampleCache() {
3333
// 3
3434
}
3535

36-
func ExampleCacheKeys() {
36+
func ExampleCache_Keys() {
3737
c := fifo.NewCache[string, int]()
3838
c.Set("foo", 1)
3939
c.Set("bar", 2)
File renamed without changes.

fifo/fifo_test.go renamed to policy/fifo/fifo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"testing"
66

7-
"github.com/Code-Hex/go-generics-cache/fifo"
7+
"github.com/Code-Hex/go-generics-cache/policy/fifo"
88
)
99

1010
func TestSet(t *testing.T) {

lfu/example_test.go renamed to policy/lfu/example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package lfu_test
33
import (
44
"fmt"
55

6-
"github.com/Code-Hex/go-generics-cache/lfu"
6+
"github.com/Code-Hex/go-generics-cache/policy/lfu"
77
)
88

9-
func ExampleLFUCache() {
9+
func ExampleNewCache() {
1010
c := lfu.NewCache[string, int]()
1111
c.Set("a", 1)
1212
c.Set("b", 2)
@@ -22,7 +22,7 @@ func ExampleLFUCache() {
2222
// 0 false
2323
}
2424

25-
func ExampleCacheKeys() {
25+
func ExampleCache_Keys() {
2626
c := lfu.NewCache[string, int]()
2727
c.Set("a", 1)
2828
c.Set("b", 2)
File renamed without changes.

0 commit comments

Comments
 (0)