MCPcopy Create free account
hub / github.com/encoder-run/operator / Module

Method Module

pkg/cache/redis/module.go:18–39  ·  view source on GitHub ↗

Module retrieves or initializes a new module-specific Storage instance.

(name string)

Source from the content-addressed store, hash-verified

16
17// Module retrieves or initializes a new module-specific Storage instance.
18func (s *ModuleStorage) Module(name string) (storage.Storer, error) {
19
20 // Check if the module exists in Redis.
21 exists, err := s.client.SIsMember(ctx, withNamespace(s.namespacePrefix, modulePrefix, ""), name).Result()
22 if err != nil {
23 return nil, err
24 }
25
26 if !exists {
27 // If the module does not exist, add it to the set of modules.
28 err = s.client.SAdd(ctx, withNamespace(s.namespacePrefix, modulePrefix, ""), name).Err()
29 if err != nil {
30 return nil, err
31 }
32 }
33
34 // Initialize a new Storage instance for the module.
35 // The module-specific namespace or prefix can be used for module-specific data.
36 moduleStorage := NewStorage(s.client.Options(), withNamespace(s.namespacePrefix, modulePrefix, ""))
37
38 return moduleStorage, nil
39}

Callers

nothing calls this directly

Calls 2

withNamespaceFunction · 0.85
NewStorageFunction · 0.70

Tested by

no test coverage detected