Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
7fba56df
Commit
7fba56df
authored
May 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X zodb: NewDB += option to set live cache control on created connections
parent
dc35035c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+23
-9
go/zodb/btree/btree_test.go
go/zodb/btree/btree_test.go
+2
-2
go/zodb/connection.go
go/zodb/connection.go
+6
-2
go/zodb/db.go
go/zodb/db.go
+13
-3
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+2
-2
No files found.
go/zodb/btree/btree_test.go
View file @
7fba56df
// Copyright (C) 2018-20
19
Nexedi SA and Contributors.
// Copyright (C) 2018-20
21
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -105,7 +105,7 @@ func TestBTree(t *testing.T) {
...
@@ -105,7 +105,7 @@ func TestBTree(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
db
:=
zodb
.
NewDB
(
stor
)
db
:=
zodb
.
NewDB
(
stor
,
&
zodb
.
DBOptions
{}
)
defer
func
()
{
defer
func
()
{
err
:=
db
.
Close
();
X
(
err
)
err
:=
db
.
Close
();
X
(
err
)
}()
}()
...
...
go/zodb/connection.go
View file @
7fba56df
// Copyright (C) 2018-202
0
Nexedi SA and Contributors.
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -180,7 +180,7 @@ const (
...
@@ -180,7 +180,7 @@ const (
// newConnection creates new Connection associated with db.
// newConnection creates new Connection associated with db.
func
newConnection
(
db
*
DB
,
at
Tid
)
*
Connection
{
func
newConnection
(
db
*
DB
,
at
Tid
)
*
Connection
{
return
&
Connection
{
conn
:=
&
Connection
{
db
:
db
,
db
:
db
,
at
:
at
,
at
:
at
,
cache
:
LiveCache
{
cache
:
LiveCache
{
...
@@ -188,6 +188,10 @@ func newConnection(db *DB, at Tid) *Connection {
...
@@ -188,6 +188,10 @@ func newConnection(db *DB, at Tid) *Connection {
objtab
:
make
(
map
[
Oid
]
*
weak
.
Ref
),
objtab
:
make
(
map
[
Oid
]
*
weak
.
Ref
),
},
},
}
}
if
cc
:=
db
.
opt
.
CacheControl
;
cc
!=
nil
{
conn
.
cache
.
SetControl
(
cc
)
}
return
conn
}
}
// DB returns database handle under which the connection was opened.
// DB returns database handle under which the connection was opened.
...
...
go/zodb/db.go
View file @
7fba56df
// Copyright (C) 2018-202
0
Nexedi SA and Contributors.
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -48,6 +48,8 @@ type DB struct {
...
@@ -48,6 +48,8 @@ type DB struct {
stor
IStorage
stor
IStorage
watchq
chan
Event
// we are watching .stor via here
watchq
chan
Event
// we are watching .stor via here
opt
*
DBOptions
down
chan
struct
{}
// ready when DB is no longer operational
down
chan
struct
{}
// ready when DB is no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
downErr
error
// reason for shutdown
downErr
error
// reason for shutdown
...
@@ -121,15 +123,23 @@ type DB struct {
...
@@ -121,15 +123,23 @@ type DB struct {
// (so it is not duplicated many times for many DB case)
// (so it is not duplicated many times for many DB case)
}
}
// DBOptions describes options to NewDB.
type
DBOptions
struct
{
// CacheControl, if !nil, is set as default live cache control for
// newly created connections.
CacheControl
LiveCacheControl
}
// NewDB creates new database handle.
// NewDB creates new database handle.
//
//
// Created database handle must be closed when no longer needed.
// Created database handle must be closed when no longer needed.
func
NewDB
(
stor
IStorage
)
*
DB
{
func
NewDB
(
stor
IStorage
,
opt
*
DBOptions
)
*
DB
{
// XXX db options?
// copy opts in case caller will change them later
opt_
:=
*
opt
db
:=
&
DB
{
db
:=
&
DB
{
stor
:
stor
,
stor
:
stor
,
watchq
:
make
(
chan
Event
),
watchq
:
make
(
chan
Event
),
opt
:
&
opt_
,
down
:
make
(
chan
struct
{}),
down
:
make
(
chan
struct
{}),
hwait
:
make
(
map
[
hwaiter
]
struct
{}),
hwait
:
make
(
map
[
hwaiter
]
struct
{}),
...
...
go/zodb/persistent_test.go
View file @
7fba56df
// Copyright (C) 2018-202
0
Nexedi SA and Contributors.
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
@@ -276,7 +276,7 @@ func (t *tDB) Reopen() {
...
@@ -276,7 +276,7 @@ func (t *tDB) Reopen() {
ReadOnly
:
true
,
ReadOnly
:
true
,
NoCache
:
!
t
.
rawcache
,
NoCache
:
!
t
.
rawcache
,
});
X
(
err
)
});
X
(
err
)
db
:=
NewDB
(
stor
)
db
:=
NewDB
(
stor
,
&
DBOptions
{}
)
t
.
stor
=
stor
t
.
stor
=
stor
t
.
db
=
db
t
.
db
=
db
}
}
...
...
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