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

Method setEncodedWithContext

shared_state.go:283–306  ·  view source on GitHub ↗
(
	ctx context.Context,
	key string,
	v any,
	ttl time.Duration,
	encoder func(any) ([]byte, error),
	format string,
)

Source from the content-addressed store, hash-verified

281}
282
283func (s *SharedState) setEncodedWithContext(
284 ctx context.Context,
285 key string,
286 v any,
287 ttl time.Duration,
288 encoder func(any) ([]byte, error),
289 format string,
290) error {
291 if err := s.ensureStorage(); err != nil {
292 return err
293 }
294
295 storageKey, ok := s.storageKey(key)
296 if !ok {
297 return nil
298 }
299
300 encoded, err := encodeSharedStateValue(v, encoder, format)
301 if err != nil {
302 return err
303 }
304
305 return s.storage.SetWithContext(ctx, storageKey, encoded, ttl)
306}
307
308// getEncodedWithContext returns a defensive copy of the encoded payload after
309// decoding it into out, so callers can safely mutate the returned slice.

Callers 4

SetJSONWithContextMethod · 0.95
SetMsgPackWithContextMethod · 0.95
SetCBORWithContextMethod · 0.95
SetXMLWithContextMethod · 0.95

Calls 4

ensureStorageMethod · 0.95
storageKeyMethod · 0.95
encodeSharedStateValueFunction · 0.85
SetWithContextMethod · 0.65

Tested by

no test coverage detected