datautil

package
v0.0.0-...-2446470 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package datautil contains general data handling objects and helper methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyObject

func CopyObject(src interface{}, dest interface{}) error

CopyObject copies contents of a given object reference to another given object reference.

Types

type MapCache

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

MapCache is a map based cache object storing string->interface{}. It is possible to specify a maximum size, which when reached causes the oldest entries to be removed. It is also possible to set an expiry time for values. Values which are old are purged on the next access to the object.

func NewMapCache

func NewMapCache(maxsize uint64, maxage int64) *MapCache

NewMapCache creates a new MapCache object. The calling function can specify the maximum size and the maximum age in seconds for entries. A value of 0 means no size constraint and no age constraint.

func (*MapCache) Get

func (mc *MapCache) Get(k string) (interface{}, bool)

Get retrieves an item from the MapCache.

func (*MapCache) Put

func (mc *MapCache) Put(k string, v interface{})

Put stores an item in the MapCache.

func (*MapCache) Remove

func (mc *MapCache) Remove(k string) bool

Remove removes an item in the MapCache.

func (*MapCache) String

func (mc *MapCache) String() string

String returns a string representation of this MapCache.

type PersistentMap

type PersistentMap struct {
	Data map[string]string // Data of the persistent map
	// contains filtered or unexported fields
}

PersistentMap is a persistent map storing string values.

func LoadPersistentMap

func LoadPersistentMap(filename string) (*PersistentMap, error)

LoadPersistentMap loads a persistent map from a file.

func NewPersistentMap

func NewPersistentMap(filename string) (*PersistentMap, error)

NewPersistentMap creates a new persistent map.

func (*PersistentMap) Flush

func (pm *PersistentMap) Flush() error

Flush writes contents of the persistent map to the disk.

Jump to

Keyboard shortcuts

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