fileCache

package module
v0.0.0-...-a499989 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 10 Imported by: 2

Documentation

Overview

Package fileCache will provide simple file content caching tools for in-Memory access to files. It uses golang/groupcache to cache your data into memory on multiple HTTP Pool servers.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ByteManifest byteManifest

ByteManifest is the in memory model for byte manifest caches

View Source
var CACHE_BOOTSTRAP_STORAGE_PATH string

CACHE_BOOTSTRAP_STORAGE_PATH is the directory where bootstrap caches are stored

View Source
var CACHE_JOBS string

CACHE_JOBS is the directory where jobs are stored

View Source
var CACHE_MANIFEST_STORAGE_PATH string

CACHE_MANIFEST_STORAGE_PATH is the directory where bootstrap caches are stored

View Source
var CACHE_STORAGE_PATH string

CACHE_STORAGE_PATH is the base GoCore path where all caches are stored

View Source
var Jobs job

Jobs is the in memory model for jobs

View Source
var Model model

Model is the in memory model for bootstrap caches

Functions

func DeleteAllBootStrapFileCache

func DeleteAllBootStrapFileCache() (err error)

DeleteAllBootstrapFileCache is exported internally to share between GoCore packages and should not be called directly by you.

func DeleteAllManifestFileCache

func DeleteAllManifestFileCache() (err error)

DeleteAllManifestFileCache is exported internally to share between GoCore packages and should not be called directly by you.

func DeleteBootStrapFileCache

func DeleteBootStrapFileCache(key string) (err error)

DeleteBootstrapCache is exported internally to share between GoCore packages and should not be called directly by you.

func DeleteManifestFileCache

func DeleteManifestFileCache(key string) (err error)

DeleteManifestFileCache is exported internally to share between GoCore packages and should not be called directly by you.

func DoesHashExistInCache

func DoesHashExistInCache(key string, value string) (exists bool)

DoesHashExistInCache is exported internally to share between GoCore packages and should not be called directly by you.

func DoesHashExistInManifestCache

func DoesHashExistInManifestCache(key string, value string) (exists bool)

DoesHashExistInManifestCache is exported internally to share between GoCore packages and should not be called directly by you.

func GetFile

func GetFile(path string) ([]byte, error)

GetFile returns binary data by path(key) from group cache

func GetHTMLFile

func GetHTMLFile(path string) (string, error)

GetHTMLFile returns the html by path (key) from group cache

func GetString

func GetString(key string) (string, error)

GetString gets a value by Key from group cache

func Init

func Init(groupCache string)

Init will initilize a groupCache if you pass a non empty string and create necessary folders for internal file caching of GoCore

func Initialize

func Initialize()

Initialize in main before any calls to this package are performed. serverSettings package must be initialized before fileCache. Developers can call SetGoCoreStoragePath() with a path of their choice for storage of where bootstrap caches and jobs files (for one time cron jobs are stored

func InitializeGroupCache

func InitializeGroupCache(domain string)

InitializeGroupCache creates the Peers for group cache and creates caches for multiple types.

func LoadCachedBootStrapFromKeyIntoMemory

func LoadCachedBootStrapFromKeyIntoMemory(key string) (err error)

LoadCachedBootStrapFileFromKeyIntoMemory is exported internally to share between GoCore packages and should not be called directly by you.

func LoadCachedManifestFromKeyIntoMemory

func LoadCachedManifestFromKeyIntoMemory(key string) (err error)

LoadCachedManifestFileFromKeyIntoMemory is exported internally to share between GoCore packages and should not be called directly by you.

func LoadJobsFile

func LoadJobsFile() (err error)

LoadJobsFile is exported internally to share between GoCore packages and should not be called directly by you.

func SetGoCoreStoragePath

func SetGoCoreStoragePath(directory string)

SetGoCoreStoragePath set a directory with a trailing slash of where you want goCore to set and make directories for caching files needed to keep track of your application cron and bootstrap caches.

func SetGroupCache

func SetGroupCache(servers []string)

SetGroupCache will update the group cache http pool. Use for dynamic systems that update at runtime.

func SetString

func SetString(key string, value string) error

SetString sets a Key value pair in group cache

Example
package main

import (
	"log"

	"github.com/DanielRenne/GoCore/core/fileCache"
)

func main() {
	fileCache.Init("127.0.0.1")
	fileCache.SetString("/somePath", "test")

	val, err := fileCache.GetString("/somePath")
	if err != nil {
		log.Println("Could not GetString: " + err.Error())
		return
	}
	log.Println(val)

	if val != "test" {
		log.Println("Error at fileCache_test.TestStringGroupCache\nFailed to return proper matching data " + err.Error())
		return
	}
	log.Println("Success!")
}
Output:

			2022/10/04 15:05:24 Initialized Group Cache Succesfully.
			2022/10/04 15:05:24 test
			2022/10/04 15:05:24 Success!

func UpdateBootStrapMemoryCache

func UpdateBootStrapMemoryCache(key string, value string)

UpdateBootstrapMemoryCache is exported internally to share between GoCore packages and should not be called directly by you.

func UpdateManifestMemoryCache

func UpdateManifestMemoryCache(key string, value string, byteSize int)

UpdateManifestMemoryCache is exported internally to share between GoCore packages and should not be called directly by you.

func WriteBootStrapCacheFile

func WriteBootStrapCacheFile(key string) (err error)

WriteBootstrapCacheFile is exported internally to share between GoCore packages and should not be called directly by you.

func WriteJobCacheFile

func WriteJobCacheFile() (err error)

WriteJobCacheFile is exported internally to share between GoCore packages and should not be called directly by you.

func WriteManifestCacheFile

func WriteManifestCacheFile(key string) (err error)

WriteManifestCacheFile is exported internally to share between GoCore packages and should not be called directly by you.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL