Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
cache.go1.57 kB
package cache import ( "context" "time" "github.com/redis/rueidis" "go.uber.org/fx" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg" "github.com/Southclaws/storyden/internal/config" "github.com/Southclaws/storyden/internal/infrastructure/cache/local" "github.com/Southclaws/storyden/internal/infrastructure/cache/redis" ) type Store interface { Get(ctx context.Context, key string) (string, error) Set(ctx context.Context, key string, object string, ttl time.Duration) error Delete(ctx context.Context, key string) error HIncrBy(ctx context.Context, key string, field string, incr int64) (int, error) HGetAll(ctx context.Context, key string) (map[string]string, error) HDel(ctx context.Context, key string, field string) error Expire(ctx context.Context, key string, expiration time.Duration) error } func Build() fx.Option { return fx.Options( fx.Provide(func(cfg config.Config) (Store, error) { switch cfg.CacheProvider { case "": c, err := local.New() return c, err case "redis": password, _ := cfg.RedisURL.User.Password() client, err := rueidis.NewClient(rueidis.ClientOption{ InitAddress: []string{cfg.RedisURL.Host}, Username: cfg.RedisURL.User.Username(), Password: password, DisableCache: true, ConnWriteTimeout: 5 * time.Second, }) if err != nil { return nil, fault.Wrap(err, fmsg.With("failed to connect to redis")) } return redis.New(client), nil } panic("unknown cache provider: " + cfg.CacheProvider) }), ) }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server