Skip to content

Commit

Permalink
Add freecache store (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev authored Jun 5, 2024
1 parent 738de1d commit 60e5232
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions nssession_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/no-src/nssession/store/buntdb"
"github.com/no-src/nssession/store/etcd"
"github.com/no-src/nssession/store/fastcache"
"github.com/no-src/nssession/store/freecache"
"github.com/no-src/nssession/store/memcached"
"github.com/no-src/nssession/store/memory"
"github.com/no-src/nssession/store/redis"
Expand Down Expand Up @@ -66,6 +67,12 @@ var (
Expiration: time.Hour,
Store: store.NewStore(fastcache.Driver),
}

freecacheConfig = &Config{
Connection: "freecache://?cache_size=50mib",
Expiration: time.Hour,
Store: store.NewStore(freecache.Driver),
}
)

func TestNSSession_Memory(t *testing.T) {
Expand Down Expand Up @@ -100,6 +107,10 @@ func TestNSSession_Fastcache(t *testing.T) {
testNSSession(t, fastcacheConfig)
}

func TestNSSession_Freecache(t *testing.T) {
testNSSession(t, freecacheConfig)
}

func testNSSession(t *testing.T, c *Config) {
InitDefaultConfig(c)
session, err := Default(createTestRequestAndWriter())
Expand Down
9 changes: 9 additions & 0 deletions store/freecache/freecache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package freecache

import (
"github.com/no-src/nscache/freecache"
"github.com/no-src/nssession/store"
)

// Driver the unique name of the freecache driver
var Driver store.DriverName = freecache.DriverName
2 changes: 2 additions & 0 deletions store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/no-src/nssession/store/buntdb"
"github.com/no-src/nssession/store/etcd"
"github.com/no-src/nssession/store/fastcache"
"github.com/no-src/nssession/store/freecache"
"github.com/no-src/nssession/store/memcached"
"github.com/no-src/nssession/store/memory"
"github.com/no-src/nssession/store/redis"
Expand All @@ -28,6 +29,7 @@ func TestStore(t *testing.T) {
{boltdb.Driver, "boltdb://boltdb.db"},
{memcached.Driver, "memcached://127.0.0.1:11211"},
{fastcache.Driver, "fastcache://?max_bytes=50mib"},
{freecache.Driver, "freecache://?cache_size=50mib"},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 60e5232

Please sign in to comment.