Skip to content

Commit

Permalink
Merge branch 'fix/docs' into main
Browse files Browse the repository at this point in the history
Signed-off-by: Alessandro Sanino <[email protected]>
  • Loading branch information
saniales committed Jun 24, 2021
2 parents 6b23ced + 5a2edae commit 993b4b7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ A set of Cache Adapters for various distributed systems (like Redis) written in

- [**MultiCache**](/multicache) -> Leverages the possibility to use multiple cache adapters at the same time, useful to create fallbacks in case one or more of the cache service you specified gives temporary errors.
- [**Redis**](/redis) -> using [`github.com/gomodule/redigo`](github.com/gomodule/redigo)
- [**InMemory**](/in_memory) -> Uses a map of objects with expiration of keys

## Library reference

Expand Down
11 changes: 0 additions & 11 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ package cacheadapters
import "fmt"

var (
// ErrNilSubAdapter will come out if you try to pass a nil sub-adapter when creating
// a new MultiCacheAdapter.
ErrNilSubAdapter = fmt.Errorf("cannot pass a nil sub-adapter to NewMultiCacheAdapter")
//ErrInvalidConnection will come out if you try to use an invalid connection in a session.
ErrInvalidConnection = fmt.Errorf("cannot use an invalid connection")
// ErrNotFound will come out if a key is not found in the cache.
ErrNotFound = fmt.Errorf("the value tried to get has not been found, check if it may be expired")
// ErrGetRequiresObjectReference will come out if a nil object
Expand All @@ -30,12 +25,6 @@ var (
// ErrInvalidTTL will come out if you try to set a zero-or-negative
// TTL in a Set operation.
ErrInvalidTTL = fmt.Errorf("cannot provide a negative TTL to Set operations")
// ErrSessionNotOpen will come out if you attempt to perform any function
// when the session is not opened yet or is already closed.
ErrSessionNotOpen = fmt.Errorf("the session is not opened yet or is closed, it cannot be used")
// ErrConnectionAlreadyOpen will come out if you try to open an already
// open session.
ErrSessionAlreadyOpen = fmt.Errorf("the session is already open, cannot be re-opened")
// errNotImplemented will come out if you are a bad dev and you did
// not implement the method which returns this error. You should see this error
// only during development.
Expand Down
4 changes: 1 addition & 3 deletions in_memory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

# Cache Adapter implementation for In Memory

A `CacheAdapter` implementation that allows to use a RAM-based memory.

Beware that at the moment it has the [**github.com/gomodule/redigo**](github.com/gomodule/redigo) dependency
A `CacheAdapter` implementation that allows to use a concurrent-safe map of objects with an expiration mechanism for the keys.

## Usage

Expand Down
8 changes: 8 additions & 0 deletions redis/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package rediscacheadapters

import "fmt"

var (
//ErrInvalidConnection will come out if you try to use an invalid connection in a session.
ErrInvalidConnection = fmt.Errorf("cannot use an invalid connection")
)
2 changes: 1 addition & 1 deletion redis/redis_session_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type RedisSessionAdapter struct {
// an existing Redis connection.
func NewSession(conn redis.Conn, defaultTTL time.Duration) (cacheadapters.CacheSessionAdapter, error) {
if conn == nil {
return nil, cacheadapters.ErrInvalidConnection
return nil, ErrInvalidConnection
}

if defaultTTL < 0 {
Expand Down
2 changes: 1 addition & 1 deletion redis/redis_session_adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (suite *RedisAdapterTestSuite) initCustomConnection() redis.Conn {
func (suite *RedisAdapterTestSuite) TestNewSession_NilConnection() {
session, err := rediscacheadapters.NewSession(nil, time.Second)
suite.Require().Nil(session, "Should be nil if I pass a nil redis connection")
suite.Require().Equal(cacheadapters.ErrInvalidConnection, err, "Should give error on nil redis connection")
suite.Require().Equal(rediscacheadapters.ErrInvalidConnection, err, "Should give error on nil redis connection")
}

func (suite *RedisAdapterTestSuite) TestNewSession_NegativeDuration() {
Expand Down

0 comments on commit 993b4b7

Please sign in to comment.