globalcache

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

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 7 Imported by: 0

README

GlobalCache

GlobalCache implements a wrapper around go-cache for Flogo.

go-cache is an in-memory key:value store/cache similar to memcached that is suitable for applications running on a single machine. Its major advantage is that, being essentially a thread-safe map[string]interface{} with expiration times, it doesn't need to serialize or transmit its contents over the network.

Installation

flogo install github.com/retgits/flogo-components/activity/globalcache

Link for flogo web:

https://github.com/retgits/flogo-components/activity/globalcache

Schema

Inputs and Outputs:

{
    "inputs": [
        {
            "name": "action",
            "type": "string",
            "allowed": [
                "INITIALIZE",
                "SET",
                "GET",
                "DELETE"
            ],
            "required": true
        },
        {
            "name": "key",
            "type": "string",
            "required": false
        },
        {
            "name": "value",
            "type": "string",
            "required": false
        },
        {
            "name": "expiryTime",
            "type": "int",
            "required": false
        },
        {
            "name": "purgeTime",
            "type": "int",
            "required": true
        }
    ],
    "outputs": [
        {
            "name": "result",
            "type": "any"
        }
    ]
}

Inputs

Input Description
action The action to perform on the cache. Allowed values are INITIALIZE (to create a new GlobalCache object), SET (to add a new key/value pair to the cache), GET (to retrieve an object from the cache), and DELETE (to remove on object from the cache)
key The name of the key to look for (during a GET or DELETE operation) or to add to the cache (during a SET operation)
value The value to add to the cache
expiryTime The expiration time of items in the cache in minutes (defaults to 5). Using -1 as expiryTime means items will never expire
purgeTime The purge time of expired items in the cache in minutes (defaults to 10)
loadset A JSON object representing key/value pairs to load while initializing the cache (like {"key":"value","retgits":"Awesome!"})

Ouputs

Output Description
result The value of the item in the cache, if it exists (will return an empty element if no entry was found)

Documentation

Overview

Package globalcache implements a wrapper around go-cache for Flogo. go-cache is an in-memory key:value store/cache similar to memcached that is suitable for applications running on a single machine. Its major advantage is that, being essentially a thread-safe map[string]interface{} with expiration times, it doesn't need to serialize or transmit its contents over the network.

Index

Constants

View Source
const (

	// CacheName represents the name of the cache as it exists in the Flogo engine
	CacheName = "GlobalCache"
	// DefaultExpiryTime is the default expiry time if no cache was created
	DefaultExpiryTime = 5
	// DefaultPurgeTime is the default purge time if no cache was created
	DefaultPurgeTime = 10
)

Variables

This section is empty.

Functions

func NewActivity

func NewActivity(metadata *activity.Metadata) activity.Activity

NewActivity creates a new activity

Types

type GlobalCache

type GlobalCache struct {
	// contains filtered or unexported fields
}

GlobalCache is an activity that governs a single engine cache

func (*GlobalCache) Eval

func (a *GlobalCache) Eval(context activity.Context) (done bool, err error)

Eval implements activity.Activity.Eval

func (*GlobalCache) Metadata

func (a *GlobalCache) Metadata() *activity.Metadata

Metadata implements activity.Activity.Metadata

Jump to

Keyboard shortcuts

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