Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
368bb3f7
Commit
368bb3f7
authored
Mar 11, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
03cc0f2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
go/zodb/connection.go
go/zodb/connection.go
+14
-8
No files found.
go/zodb/connection.go
View file @
368bb3f7
...
...
@@ -65,6 +65,13 @@ type Connection struct {
//
// Use .Lock() / .Unlock() to serialize access.
type
LiveCache
struct
{
sync
.
Mutex
// pinned objects. may have referees.
pinned
map
[
Oid
]
IPersistent
// not pinned objects. may have referees. cache keeps weak reference to an object.
//
// rationale for using weakref:
//
// on invalidations: we need to go oid -> obj and invalidate it.
...
...
@@ -111,12 +118,6 @@ type LiveCache struct {
//
// NOTE2 finalizers don't run on when they are attached to an object in cycle.
// Hopefully we don't have cycles with BTree/Bucket.
sync
.
Mutex
// pinned objects. may have referees.
pinned
map
[
Oid
]
IPersistent
// not pinned objects. may have referees.
objtab
map
[
Oid
]
*
weak
.
Ref
// oid -> weak.Ref(IPersistent)
// hooks for application to influence live caching decisions.
...
...
@@ -155,13 +156,13 @@ const (
//
// Note: on invalidation, state of invalidated objects is discarded
// unconditionally.
PCacheKeepState
// XXX PCachePolicy explicitly?
PCacheKeepState
// data access is non-temporal.
//
// Object state is used once and then won't be used for a long time.
// Don't pollute cache with this object state.
PCacheNonTemporal
// XXX PCache
Policy
?
PCacheNonTemporal
// XXX PCache
ForgetState? DropState
?
)
// ----------------------------------------
...
...
@@ -203,11 +204,14 @@ func (e *wrongClassError) Error() string {
// If object is found, it is guaranteed to stay in live cache while the caller keeps reference to it.
// LiveCacheControl can be used to extend that guarantee.
func
(
cache
*
LiveCache
)
Get
(
oid
Oid
)
IPersistent
{
// 1. lookup in pinned objects (potentially hottest)
obj
:=
cache
.
pinned
[
oid
]
if
obj
!=
nil
{
return
obj
}
// 2. lookup in referenced object (they are likely to be loaded as
// other objects reference them)
wobj
:=
cache
.
objtab
[
oid
]
if
wobj
!=
nil
{
if
xobj
:=
wobj
.
Get
();
xobj
!=
nil
{
...
...
@@ -215,6 +219,8 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
}
}
// 3. TODO lookup in non-referenced LRU
return
obj
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment