Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-server
Commits
4958e1d6
Verified
Commit
4958e1d6
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
EHN: ETag property for the Query
parent
2674aa54
No related branches found
Branches containing commit
No related tags found
Tags containing commit
4 merge requests
!21
Release v0.4.0
,
!7
F fsm
,
!6
Draft: F acm permissions2
,
!1
F etag
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+4
-0
4 additions, 0 deletions
CHANGELOG.md
src/main/java/org/caosdb/server/query/Query.java
+17
-4
17 additions, 4 deletions
src/main/java/org/caosdb/server/query/Query.java
with
21 additions
and
4 deletions
CHANGELOG.md
+
4
−
0
View file @
4958e1d6
...
...
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
*
`ETag`
property for the query. The
`ETag`
tags a server state and is being
updated each time the server state is being updated (i.e. the stored entities
change). This can be used to debug the query cache and also allows a client
to determine whether the server's state has changed between queries.
*
Basic caching for queries. The caching is enabled by default and can be
controlled by the usual "cache" flag.
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/caosdb/server/query/Query.java
+
17
−
4
View file @
4958e1d6
...
...
@@ -39,6 +39,7 @@ import java.util.LinkedList;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.UUID
;
import
org.antlr.v4.runtime.CharStreams
;
import
org.antlr.v4.runtime.CommonTokenStream
;
import
org.apache.commons.jcs.access.behavior.ICacheAccess
;
...
...
@@ -238,6 +239,14 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
*/
private
boolean
cachable
=
true
;
/**
* Tags the query cache and is renewed each time the cache is being cleared, i.e. each time the
* database is being updated.
*
* <p>As the name suggests, the idea is similar to the ETag header of the HTTP protocol.
*/
private
static
String
cacheETag
=
UUID
.
randomUUID
().
toString
();
public
Type
getType
()
{
return
this
.
type
;
}
...
...
@@ -668,6 +677,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
/** Remove all cached queries from the cache. */
public
static
void
clearCache
()
{
cacheETag
=
UUID
.
randomUUID
().
toString
();
cache
.
clear
();
}
...
...
@@ -678,10 +688,12 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
* @param resultSet
*/
private
void
setCache
(
String
key
,
List
<
IdVersionPair
>
resultSet
)
{
if
(
resultSet
instanceof
Serializable
)
{
cache
.
put
(
key
,
(
Serializable
)
resultSet
);
}
else
{
cache
.
put
(
key
,
new
ArrayList
<>(
resultSet
));
synchronized
(
cache
)
{
if
(
resultSet
instanceof
Serializable
)
{
cache
.
put
(
key
,
(
Serializable
)
resultSet
);
}
else
{
cache
.
put
(
key
,
new
ArrayList
<>(
resultSet
));
}
}
}
...
...
@@ -859,6 +871,7 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac
ret
.
setAttribute
(
"results"
,
"0"
);
}
ret
.
setAttribute
(
"cached"
,
Boolean
.
toString
(
this
.
cached
));
ret
.
setAttribute
(
"etag"
,
cacheETag
);
final
Element
parseTreeElem
=
new
Element
(
"ParseTree"
);
if
(
this
.
el
.
hasErrors
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment