-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8505d83
commit 83cbe8b
Showing
7 changed files
with
128 additions
and
7 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
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,29 @@ | ||
package zwis | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type CacheType string | ||
|
||
const ( | ||
MemoryCacheType CacheType = "memory" | ||
LRUCacheType CacheType = "lru" | ||
LFUCacheType CacheType = "lfu" | ||
ARCCacheType CacheType = "arc" | ||
) | ||
|
||
func NewCache(cacheType CacheType, capacity int) (Cache, error) { | ||
switch cacheType { | ||
case MemoryCacheType: | ||
return NewMemoryCache(), nil | ||
case LRUCacheType: | ||
return NewLRUCache(capacity), nil | ||
case LFUCacheType: | ||
return NewLFUCache(capacity), nil | ||
case ARCCacheType: | ||
return NewARCCache(capacity), nil | ||
default: | ||
return nil, fmt.Errorf("unknown cache type: %s", cacheType) | ||
} | ||
} |
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