Documentation
¶
Index ¶
- type CacheConfig
- type CacheEntry
- type CacheIndex
- type CacheManager
- func (cm *CacheManager) Clear() error
- func (cm *CacheManager) GenerateCacheKey(path string, content []byte, configHash string) string
- func (cm *CacheManager) GetCachePath(key string) string
- func (cm *CacheManager) GetEntry(key string) (*CacheEntry, bool)
- func (cm *CacheManager) GetStats() *CacheStats
- func (cm *CacheManager) Initialize() error
- func (cm *CacheManager) SetEntry(key string, entry *CacheEntry) error
- func (cm *CacheManager) SetFileSystem(fs filesystem.FileSystem)
- type CacheStats
- type SvelteCache
- func (sc *SvelteCache) CompileWithCache(path string, content []byte, configHash string, ...) (*SvelteCacheEntry, error)
- func (sc *SvelteCache) Get(path string, content []byte, configHash string) (*SvelteCacheEntry, bool)
- func (sc *SvelteCache) GetStats() map[string]interface{}
- func (sc *SvelteCache) InvalidateDependents(path string) error
- func (sc *SvelteCache) InvalidatePath(path string) error
- func (sc *SvelteCache) Precompile(path string, content []byte, configHash string, vm *goja.Runtime) error
- func (sc *SvelteCache) Set(path string, content []byte, configHash string, compiled *SvelteCacheEntry) error
- type SvelteCacheEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheConfig ¶
type CacheConfig struct {
RootDir string // Project root directory
CacheDir string // Custom cache directory (optional)
Enabled bool // Whether cache is enabled
MaxSize int64 // Maximum cache size in bytes
TTL time.Duration // Cache expiration time
CompressCache bool // Whether to compress cache
}
CacheConfig represents cache configuration
type CacheEntry ¶
type CacheEntry struct {
Path string `json:"path"`
Hash string `json:"hash"` // Content MD5
ConfigHash string `json:"configHash"` // Config hash
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
AccessTime time.Time `json:"accessTime"`
AccessCount int `json:"accessCount"`
Priority float64 `json:"priority"` // Compilation priority
}
CacheEntry represents a single cache entry
type CacheIndex ¶
type CacheIndex struct {
Version string `json:"version"`
RediVersion string `json:"rediVersion"`
Created time.Time `json:"created"`
LastUpdated time.Time `json:"lastUpdated"`
Entries map[string]*CacheEntry `json:"entries"`
TotalSize int64 `json:"totalSize"`
EntryCount int `json:"entryCount"`
}
CacheIndex represents the cache index
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages the cache system
func NewCacheManager ¶
func NewCacheManager(config *CacheConfig) *CacheManager
NewCacheManager creates a new cache manager
func (*CacheManager) GenerateCacheKey ¶
func (cm *CacheManager) GenerateCacheKey(path string, content []byte, configHash string) string
generateCacheKey generates a cache key from path and content
func (*CacheManager) GetCachePath ¶
func (cm *CacheManager) GetCachePath(key string) string
GetCachePath returns the full path for a cache key
func (*CacheManager) GetEntry ¶
func (cm *CacheManager) GetEntry(key string) (*CacheEntry, bool)
GetEntry retrieves a cache entry
func (*CacheManager) GetStats ¶
func (cm *CacheManager) GetStats() *CacheStats
GetStats returns cache statistics
func (*CacheManager) Initialize ¶
func (cm *CacheManager) Initialize() error
Initialize initializes the cache system
func (*CacheManager) SetEntry ¶
func (cm *CacheManager) SetEntry(key string, entry *CacheEntry) error
SetEntry sets a cache entry
func (*CacheManager) SetFileSystem ¶
func (cm *CacheManager) SetFileSystem(fs filesystem.FileSystem)
SetFileSystem sets the filesystem implementation
type CacheStats ¶
type CacheStats struct {
TotalEntries int `json:"totalEntries"`
TotalSize int64 `json:"totalSize"`
HitRate float64 `json:"hitRate"`
AvgCompileTime time.Duration `json:"avgCompileTime"`
TopAccessed []string `json:"topAccessed"`
}
CacheStats provides cache statistics
type SvelteCache ¶
type SvelteCache struct {
// contains filtered or unexported fields
}
SvelteCache manages Svelte component compilation caching
func NewSvelteCache ¶
func NewSvelteCache(manager *CacheManager, fs filesystem.FileSystem) *SvelteCache
NewSvelteCache creates a new Svelte cache instance
func (*SvelteCache) CompileWithCache ¶
func (sc *SvelteCache) CompileWithCache( path string, content []byte, configHash string, compileFunc func() (*SvelteCacheEntry, error), ) (*SvelteCacheEntry, error)
CompileWithCache compiles a Svelte component with caching
func (*SvelteCache) Get ¶
func (sc *SvelteCache) Get(path string, content []byte, configHash string) (*SvelteCacheEntry, bool)
Get retrieves a cached component
func (*SvelteCache) GetStats ¶
func (sc *SvelteCache) GetStats() map[string]interface{}
GetStats returns cache statistics
func (*SvelteCache) InvalidateDependents ¶
func (sc *SvelteCache) InvalidateDependents(path string) error
InvalidateDependents invalidates cache for components that depend on a path
func (*SvelteCache) InvalidatePath ¶
func (sc *SvelteCache) InvalidatePath(path string) error
InvalidatePath invalidates cache for a specific path
func (*SvelteCache) Precompile ¶
func (sc *SvelteCache) Precompile(path string, content []byte, configHash string, vm *goja.Runtime) error
Precompile attempts to precompile a component and cache it
func (*SvelteCache) Set ¶
func (sc *SvelteCache) Set(path string, content []byte, configHash string, compiled *SvelteCacheEntry) error
Set stores a compiled component in cache
type SvelteCacheEntry ¶
type SvelteCacheEntry struct {
// Metadata
Path string `json:"path"`
Hash string `json:"hash"`
ConfigHash string `json:"configHash"`
CompileTime time.Duration `json:"compileTime"`
Timestamp time.Time `json:"timestamp"`
// Compiled output
JavaScript string `json:"javascript"`
CSS string `json:"css"`
ClassName string `json:"className"`
// Dependencies
Dependencies []string `json:"dependencies"`
Imports map[string]string `json:"imports"`
// Runtime flags
HasVimeshStyle bool `json:"hasVimeshStyle"`
IsMinified bool `json:"isMinified"`
// Runtime-only fields (not persisted)
WasFromCache bool `json:"-"` // Indicates if this entry was loaded from cache
}
SvelteCacheEntry represents a cached Svelte component