MCPcopy
hub / github.com/gofiber/fiber / getRaw

Method getRaw

middleware/cache/manager.go:141–162  ·  view source on GitHub ↗

get raw data from storage or memory

(ctx context.Context, key string)

Source from the content-addressed store, hash-verified

139
140// get raw data from storage or memory
141func (m *manager) getRaw(ctx context.Context, key string) ([]byte, error) {
142 if m.storage != nil {
143 raw, err := m.storage.GetWithContext(ctx, key)
144 if err != nil {
145 return nil, fmt.Errorf("cache: failed to get raw key %q from storage: %w", m.logKey(key), err)
146 }
147 if raw == nil {
148 return nil, errCacheMiss
149 }
150 return raw, nil
151 }
152
153 if value := m.memory.Get(key); value != nil {
154 raw, ok := value.([]byte)
155 if !ok {
156 return nil, fmt.Errorf("cache: unexpected raw entry type %T for key %q", value, m.logKey(key))
157 }
158 return raw, nil
159 }
160
161 return nil, errCacheMiss
162}
163
164// set data to storage or memory
165func (m *manager) set(ctx context.Context, key string, it *item, exp time.Duration) error {

Callers 3

NewFunction · 0.45
loadVaryManifestFunction · 0.45

Calls 4

logKeyMethod · 0.95
GetWithContextMethod · 0.65
ErrorfMethod · 0.65
GetMethod · 0.65

Tested by 1