cache

package
v0.0.0-...-8ad63dc Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a struct that stores the compiled nodes to prevent expensive parsing and compiling of DFL expressions.

func New

func New() *Cache

NewCache returns a new node cache

func (*Cache) Get

func (c *Cache) Get(exp string) (dfl.Node, bool)

Get returns the node for the given expression and true, if a valid node is found. Otherwise, Get returns (nil, false).

func (*Cache) Has

func (c *Cache) Has(exp string) bool

Has returns true if the cache has the Node for the given expression in the cache.

func (*Cache) MustParseCompile

func (c *Cache) MustParseCompile(exp string) dfl.Node

MustParseCompile parses and compiles the expression and then sets the resulting node in the cache.

func (*Cache) ParseCompile

func (c *Cache) ParseCompile(exp string) (dfl.Node, error)

Parse and compile the DFL expression. If the expression was already compiled, use the version found in the cache. Otherwise,

func (*Cache) Set

func (c *Cache) Set(exp string, node dfl.Node)

Set adds the given node to the cache with the expression as key.

Jump to

Keyboard shortcuts

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