-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHANGE: - server/peerStore/peerStore implemented in `peerStore/peerstore.go` All other changes accompany these changes.
- Loading branch information
1 parent
750c281
commit 3692f72
Showing
8 changed files
with
100 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package redisPeerStoreImpl | ||
|
||
import ( | ||
"github.com/GrappigPanda/notorious/peerStore/redis" | ||
"gopkg.in/redis.v3" | ||
) | ||
|
||
// RedisStore represents the implementation of a `PeerStore` object. | ||
type RedisStore struct { | ||
client *redis.Client | ||
} | ||
|
||
// SetKeyIfNotExists wraps around the generic RedisSetKeyIfNotExists function | ||
func (p *RedisStore) SetKeyIfNotExists(key, value string) (retval bool) { | ||
return redisPeerStore.SetKeyIfNotExists(p.client, key, value) | ||
} | ||
|
||
// SetKV wraps around the generic `SetKeyVal` function | ||
func (p *RedisStore) SetKV(key, value string) { | ||
redisPeerStore.SetKeyVal(p.client, key, value) | ||
} | ||
|
||
// RemoveKV wraps around the specific `RemoveKeysValue` function | ||
func (p *RedisStore) RemoveKV(key, value string) { | ||
// TODO(ian): Refactor this so we don't have to delete a value from a key | ||
if value != "" || value == "" { | ||
redisPeerStore.RemoveKeysValue(p.client, key, value) | ||
} | ||
} | ||
|
||
// KeyExists wraps around the specific `GetBoolKeyVal` function | ||
func (p *RedisStore) KeyExists(key string) (retval bool) { | ||
return redisPeerStore.GetBoolKeyVal(p.client, key) | ||
} | ||
|
||
// GetKeyVal wraps around the specific `GetKeyVal` function | ||
func (p *RedisStore) GetKeyVal(key string) []string { | ||
return redisPeerStore.GetKeyVal(p.client, key) | ||
} | ||
|
||
// GetAllPeers wraps around the specific `GetAllPeers` function | ||
func (p *RedisStore) GetAllPeers(key string) []string { | ||
return redisPeerStore.GetAllPeers(p.client, key) | ||
} | ||
|
||
// SetIPMember wraps around the specific `SetIPMember` function | ||
func (p *RedisStore) SetIPMember(infoHash, ipPort string) (retval int) { | ||
return redisPeerStore.SetIPMember(p.client, infoHash, ipPort) | ||
} | ||
|
||
// CreateNewTorrentKey wraps around the specific `CreateNewTorrentKey` function | ||
func (p *RedisStore) CreateNewTorrentKey(infoHash string) { | ||
redisPeerStore.CreateNewTorrentKey(p.client, infoHash) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters