isErrorTemporarilyUnavailable checks if an error is due to a resource being temporarily unavailable.
(err error)
| 133 | |
| 134 | // isErrorTemporarilyUnavailable checks if an error is due to a resource being temporarily unavailable. |
| 135 | func isErrorTemporarilyUnavailable(err error) bool { |
| 136 | if err == nil { |
| 137 | return false |
| 138 | } |
| 139 | |
| 140 | // Check if the error is EAGAIN or EWOULDBLOCK (resource temporarily unavailable) |
| 141 | if pathErr, ok := err.(*os.PathError); ok { |
| 142 | if errno, ok := pathErr.Err.(syscall.Errno); ok { |
| 143 | return errno == syscall.EAGAIN || errno == syscall.EWOULDBLOCK |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Also check the error string as a fallback |
| 148 | return err.Error() == "resource temporarily unavailable" |
| 149 | } |
| 150 | |
| 151 | // Get retrieves data from the cache. |
| 152 | func (c *BadgerCache) Get(key string, dest interface{}) (bool, error) { |