Documentation ¶
Overview ¶
WIP: Package hdb provides a "handle"/value DB like store, but actually it's closer to the model of a process's virtual memory and its alloc, free and move methods.
The hdb package is a thin layer around falloc.File providing stable-only handles and the basic synchronizing primitives. The central functionality of hdb are the New, Set, Get and Delete methods of Store.
Conceptual analogy:
New alloc(sizeof(content)), return new "memory" pointer (a handle). Get memmove() from "memory" "pointed to" by handle to the result content. Note: Handle "knows" the size of its content. Set memmove() from content to "memory" pointed to by handle. In contrast to real memory, the new content may have different size than the previously stored one w/o additional handling and the "pointer" handle remains the same. Delete free() the "memory" "pointed to" by handle.
Index ¶
- type Store
- func (s *Store) Close() (err error)
- func (s *Store) Delete(handle falloc.Handle) (err error)
- func (s *Store) File() *falloc.File
- func (s *Store) Get(handle falloc.Handle) (b []byte, err error)
- func (s *Store) Lock()
- func (s *Store) LockedDelete(handle falloc.Handle) (err error)
- func (s *Store) LockedGet(handle falloc.Handle) (b []byte, err error)
- func (s *Store) LockedNew(b []byte) (handle falloc.Handle, err error)
- func (s *Store) LockedSet(handle falloc.Handle, b []byte) (err error)
- func (s *Store) New(b []byte) (handle falloc.Handle, err error)
- func (s *Store) RLock()
- func (s *Store) RUnlock()
- func (s *Store) Root() falloc.Handle
- func (s *Store) Set(handle falloc.Handle, b []byte) (err error)
- func (s *Store) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func New ¶
New returns a newly created Store backed by accessor, discarding its conents if any. If successful, methods on the returned Store can be used for I/O. It returns the Store and an error, if any.
func Open ¶
Open opens the Store from accessor. If successful, methods on the returned Store can be used for data exchange. It returns the Store and an error, if any.
func (*Store) Close ¶
Close closes the store. Further access to the store has undefined behavior and may panic. It returns an error, if any.
func (*Store) Get ¶
Get gets the data associated with handle. It returns the data and an error, if any.
func (*Store) Lock ¶
func (s *Store) Lock()
Lock locks 's' for writing. If the lock is already locked for reading or writing, Lock blocks until the lock is available. To ensure that the lock eventually becomes available, a blocked Lock call excludes new readers from acquiring the lock.
func (*Store) LockedDelete ¶
LockedDelete wraps Delete in a Lock/Unlock pair.
func (*Store) New ¶
New associates data with a new handle. It returns the handle and an error, if any.
func (*Store) RLock ¶
func (s *Store) RLock()
RLock locks 's' for reading. If the lock is already locked for writing or there is a writer already waiting to release the lock, RLock blocks until the writer has released the lock.
func (*Store) RUnlock ¶
func (s *Store) RUnlock()
RUnlock undoes a single RLock call; it does not affect other simultaneous readers. It's a run-time error if 's' is not locked for reading on entry to RUnlock.
func (*Store) Unlock ¶
func (s *Store) Unlock()
Unlock unlocks 's' for writing. It's a run-time error if 's' is not locked for writing on entry to Unlock.
As with Mutexes, a locked RWMutex is not associated with a particular goroutine. One goroutine may RLock (Lock) 's' and then arrange for another goroutine to RUnlock (Unlock) it.