Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteViewPrefixes ¶ added in v0.0.24
func DeleteViewPrefixes(ctx jsutil.AsyncContext, prefixes []string, store Area) error
DeleteViewPrefixes deletes all storage entries for views with the given prefixes.
Types ¶
type Area ¶
type Area interface { // Set stores new data in storage. data is a map of key-value pairs to // be stored. If a key already exists, it will be overwritten. Set(ctx jsutil.AsyncContext, data map[string]js.Value) error // Get reads all the data items currently stored. The data returned is a // map of key-value pairs, with each representing a distinct item from // storage. Get(ctx jsutil.AsyncContext) (map[string]js.Value, error) // Delete removes the items from storage with the specified keys. If a // key is not found in storage, it will be silently ignored (i.e., no // error will be returned). Delete(ctx jsutil.AsyncContext, keys []string) error }
Area implementations provide access to underlying storage. The interface is a simplified subset of the StorageArea API:
https://developer.chrome.com/docs/extensions/reference/storage/#type-StorageArea
func DefaultSession ¶
func DefaultSession() Area
DefaultSession returns an Area that can store and retrieve in-memory data. The data is not written to disk. See:
https://developer.chrome.com/docs/extensions/reference/storage/#property-session
func DefaultSync ¶
func DefaultSync() Area
DefaultSync returns an Area that can store and retrieve data that is synced between the user's devices. See:
https://developer.chrome.com/docs/extensions/reference/storage/#property-sync
type Big ¶
type Big struct {
// contains filtered or unexported fields
}
Big supports storing and retrieving keys and values of arbitrary sizes. Items that fit within the per-item quota are stored normally; larger ones are split into multiple chunks.
Overall storage quota still applies, but this bypasses the per-item quotas.
Big implements the Area interface.
func (*Big) Delete ¶
func (b *Big) Delete(ctx jsutil.AsyncContext, keys []string) error
See PersistentStore.Delete().
type Raw ¶
type Raw struct {
// contains filtered or unexported fields
}
Raw supports storing and retrieving data using Chrome's Storage API.
Raw implements the Area interface.
func NewRaw ¶
NewRaw returns a Raw for storing and retrieving data. The specified area must point to an object implmenting the StorageArea API.
func (*Raw) Delete ¶
func (r *Raw) Delete(ctx jsutil.AsyncContext, keys []string) error
Delete implements Area.Delete().
type Typed ¶
type Typed[V any] struct { // contains filtered or unexported fields }
Typed reads and writes typed values. They are serialized upon writing, and deserialized upon reading. If deserialization fails for a given value, it is ignored.
func NewTyped ¶
NewTyped returns a new Typed using the underlying persistent store. keyPrefix is the prefix used to distinguish values from others in the same underlying store; multiple may be supplied to support migration scenarios.
func (*Typed[V]) Delete ¶
func (t *Typed[V]) Delete(ctx jsutil.AsyncContext, test func(v *V) bool) error
Delete removes the value that matches the supplied test function. If multiple values match, all matching values are removed.
func (*Typed[V]) Read ¶
func (t *Typed[V]) Read(ctx jsutil.AsyncContext, test func(v *V) bool) (*V, error)
Read returns a single value that matches the supplied test function. If multiple values match, only the first is returned. If the value is not found, a nil value is returned.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View supports storing and retrieving keys and values with particular key prefix. This allows multiple usages of the same underlying datastore, without them trampling on each other.
It is the caller's responsibility to supply unique key prefixes as required.
func (*View) Delete ¶
func (v *View) Delete(ctx jsutil.AsyncContext, keys []string) error
Delete implements Area.Delete().