Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farzai/cache-go
https://github.com/farzai/cache-go
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/farzai/cache-go
- Owner: farzai
- License: mit
- Created: 2023-07-13T08:01:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-03T06:41:17.000Z (over 1 year ago)
- Last Synced: 2024-11-12T13:28:14.496Z (2 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cache - GO
A simple cache library for golang.
## Installation
```bash
go get github.com/farzai/cache-go
```## Usage
```go
package mainimport (
"fmt"
"time""github.com/farzai/cache-go"
)func main() {
cache := cache.NewCache(cache.NewRedisDriver("localhost:6379", "", 0, 10*time.Second))
// Or
// cache := cache.NewCache(cache.NewMemoryDriver(10*time.Second))
// cache := cache.NewCache(cache.NewLocalFileDriver("/storage/cache", 10*time.Second))err := cache.Set("key", "value")
if err != nil {
fmt.Println("Error setting value in cache:", err)
return
}value, err := cache.Get("key")
if err != nil {
fmt.Println("Error getting value from cache:", err)
return
}fmt.Println("Value from cache:", value)
}
```## License
Please see the [LICENSE](LICENSE) file for more information.