Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
315
Merge Requests
315
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
4a677afc
Commit
4a677afc
authored
Aug 26, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1754142
by Damien Tournoud: Move CACHE_PERMANENT out of bootstrap.inc.
parent
16005119
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
27 deletions
+28
-27
core/includes/bootstrap.inc
core/includes/bootstrap.inc
+0
-7
core/includes/common.inc
core/includes/common.inc
+4
-3
core/lib/Drupal/Core/Cache/CacheBackendInterface.php
core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+10
-3
core/lib/Drupal/Core/Cache/DatabaseBackend.php
core/lib/Drupal/Core/Cache/DatabaseBackend.php
+2
-2
core/lib/Drupal/Core/Cache/InstallBackend.php
core/lib/Drupal/Core/Cache/InstallBackend.php
+1
-1
core/lib/Drupal/Core/Cache/MemoryBackend.php
core/lib/Drupal/Core/Cache/MemoryBackend.php
+1
-1
core/lib/Drupal/Core/Cache/NullBackend.php
core/lib/Drupal/Core/Cache/NullBackend.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
...al/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
+7
-7
core/modules/update/update.module
core/modules/update/update.module
+2
-2
No files found.
core/includes/bootstrap.inc
View file @
4a677afc
...
...
@@ -36,13 +36,6 @@
*/
const
DRUPAL_MINIMUM_PHP_MEMORY_LIMIT
=
'32M'
;
/**
* Indicates that the item should never be removed unless explicitly selected.
*
* The item may be removed using cache()->delete() with a cache ID.
*/
const
CACHE_PERMANENT
=
0
;
/**
* @defgroup logging_severity_levels Logging severity levels
* @{
...
...
core/includes/common.inc
View file @
4a677afc
...
...
@@ -3,6 +3,7 @@
use
Drupal\Component\Utility\NestedArray
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Drupal\Core\Cache\CacheBackendInterface
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Template\Attribute
;
...
...
@@ -4988,7 +4989,7 @@ function drupal_page_set_cache($body) {
'headers'
=>
array
(),
),
'tags'
=>
array
(
'content'
=>
TRUE
),
'expire'
=>
CACHE_PERMANENT
,
'expire'
=>
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
'created'
=>
REQUEST_TIME
,
);
...
...
@@ -5908,7 +5909,7 @@ function drupal_render_cache_set(&$markup, $elements) {
$data
[
'#attached'
]
=
$attached
;
}
$bin
=
isset
(
$elements
[
'#cache'
][
'bin'
])
?
$elements
[
'#cache'
][
'bin'
]
:
'cache'
;
$expire
=
isset
(
$elements
[
'#cache'
][
'expire'
])
?
$elements
[
'#cache'
][
'expire'
]
:
CACHE_PERMANENT
;
$expire
=
isset
(
$elements
[
'#cache'
][
'expire'
])
?
$elements
[
'#cache'
][
'expire'
]
:
C
acheBackendInterface
::
C
ACHE_PERMANENT
;
$tags
=
isset
(
$elements
[
'#cache'
][
'tags'
])
?
$elements
[
'#cache'
][
'tags'
]
:
array
();
cache
(
$bin
)
->
set
(
$cid
,
$data
,
$expire
,
$tags
);
}
...
...
@@ -5983,7 +5984,7 @@ function drupal_render_collect_attached($elements, $return = FALSE) {
* - #pre_render: $function with a _pre_render suffix.
* - #cache: An associative array prepared for drupal_render_cache_set().
*/
function
drupal_render_cache_by_query
(
$query
,
$function
,
$expire
=
CACHE_PERMANENT
,
$granularity
=
NULL
)
{
function
drupal_render_cache_by_query
(
$query
,
$function
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
$granularity
=
NULL
)
{
$cache_keys
=
array_merge
(
array
(
$function
),
drupal_render_cid_parts
(
$granularity
));
$query
->
preExecute
();
$cache_keys
[]
=
hash
(
'sha256'
,
serialize
(
array
((
string
)
$query
,
$query
->
getArguments
())));
...
...
core/lib/Drupal/Core/Cache/CacheBackendInterface.php
View file @
4a677afc
...
...
@@ -47,6 +47,13 @@
*/
interface
CacheBackendInterface
{
/**
* Indicates that the item should never be removed unless explicitly selected.
*
* The item may be removed using cache()->delete() with a cache ID.
*/
const
CACHE_PERMANENT
=
0
;
/**
* Constructs a new cache backend.
*
...
...
@@ -93,8 +100,8 @@ function getMultiple(&$cids);
* Strings will be stored as plain text and not serialized.
* @param $expire
* One of the following values:
* - C
ACHE_PERMANENT: Indicates that the item should never be removed unless
*
explicitly told to using cache->delete($cid)
.
* - C
acheBackendInterface::CACHE_PERMANENT: Indicates that the item
*
should never be removed unless cache->delete($cid) is used explicitly
.
* - A Unix timestamp: Indicates that the item should be kept at least until
* the given time.
* @param array $tags
...
...
@@ -104,7 +111,7 @@ function getMultiple(&$cids);
* a node, both the node ID and the author's user ID might be passed in as
* tags. For example array('node' => array(123), 'user' => array(92)).
*/
function
set
(
$cid
,
$data
,
$expire
=
CACHE_PERMANENT
,
array
$tags
=
array
());
function
set
(
$cid
,
$data
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
$tags
=
array
());
/**
* Deletes an item from the cache.
...
...
core/lib/Drupal/Core/Cache/DatabaseBackend.php
View file @
4a677afc
...
...
@@ -117,7 +117,7 @@ protected function prepareItem($cache) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/
function
set
(
$cid
,
$data
,
$expire
=
CACHE_PERMANENT
,
array
$tags
=
array
())
{
function
set
(
$cid
,
$data
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
$tags
=
array
())
{
$fields
=
array
(
'serialized'
=>
0
,
'created'
=>
REQUEST_TIME
,
...
...
@@ -188,7 +188,7 @@ function flush() {
*/
function
expire
()
{
db_delete
(
$this
->
bin
)
->
condition
(
'expire'
,
CACHE_PERMANENT
,
'<>'
)
->
condition
(
'expire'
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
'<>'
)
->
condition
(
'expire'
,
REQUEST_TIME
,
'<'
)
->
execute
();
}
...
...
core/lib/Drupal/Core/Cache/InstallBackend.php
View file @
4a677afc
...
...
@@ -50,7 +50,7 @@ function getMultiple(&$cids) {
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::set().
*/
function
set
(
$cid
,
$data
,
$expire
=
CACHE_PERMANENT
,
array
$tags
=
array
())
{}
function
set
(
$cid
,
$data
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
$tags
=
array
())
{}
/**
* Overrides Drupal\Core\Cache\DatabaseBackend::delete().
...
...
core/lib/Drupal/Core/Cache/MemoryBackend.php
View file @
4a677afc
...
...
@@ -95,7 +95,7 @@ protected function prepareItem($cache) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/
public
function
set
(
$cid
,
$data
,
$expire
=
CACHE_PERMANENT
,
array
$tags
=
array
())
{
public
function
set
(
$cid
,
$data
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
$tags
=
array
())
{
$this
->
cache
[
$cid
]
=
(
object
)
array
(
'cid'
=>
$cid
,
'data'
=>
$data
,
...
...
core/lib/Drupal/Core/Cache/NullBackend.php
View file @
4a677afc
...
...
@@ -42,7 +42,7 @@ function getMultiple(&$cids) {
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/
function
set
(
$cid
,
$data
,
$expire
=
CACHE_PERMANENT
,
array
$tags
=
array
())
{}
function
set
(
$cid
,
$data
,
$expire
=
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
$tags
=
array
())
{}
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete().
...
...
core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
View file @
4a677afc
...
...
@@ -377,7 +377,7 @@ public function testFlush() {
$backend
=
$this
->
getCacheBackend
();
// Set both expiring and permanent keys.
$backend
->
set
(
'test1'
,
1
,
CACHE_PERMANENT
);
$backend
->
set
(
'test1'
,
1
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
);
$backend
->
set
(
'test2'
,
3
,
time
()
+
1000
);
$backend
->
flush
();
...
...
@@ -411,8 +411,8 @@ function testClearTags() {
$backend
=
$this
->
getCacheBackend
();
// Create two cache entries with the same tag and tag value.
$backend
->
set
(
'test_cid_clear1'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$backend
->
set
(
'test_cid_clear2'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$backend
->
set
(
'test_cid_clear1'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$backend
->
set
(
'test_cid_clear2'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear1'
)
&&
$this
->
checkCacheExists
(
'test_cid_clear2'
),
'Two cache items were created.'
);
...
...
@@ -423,9 +423,9 @@ function testClearTags() {
'Two caches removed after clearing a cache tag.'
);
// Create three cache entries with a mix of tags and tag values.
$backend
->
set
(
'test_cid_clear1'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$backend
->
set
(
'test_cid_clear2'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
2
)));
$backend
->
set
(
'test_cid_clear3'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
array
(
'test_tag_foo'
=>
array
(
3
)));
$backend
->
set
(
'test_cid_clear1'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
1
)));
$backend
->
set
(
'test_cid_clear2'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
(
'test_tag'
=>
array
(
2
)));
$backend
->
set
(
'test_cid_clear3'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
array
(
'test_tag_foo'
=>
array
(
3
)));
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test_cid_clear1'
)
&&
$this
->
checkCacheExists
(
'test_cid_clear2'
)
&&
$this
->
checkCacheExists
(
'test_cid_clear3'
),
...
...
@@ -443,7 +443,7 @@ function testClearTags() {
$tags
=
array
(
'test_tag'
=>
array
(
1
,
2
,
3
));
$bins
=
array
(
'path'
,
'bootstrap'
,
'page'
);
foreach
(
$bins
as
$bin
)
{
$this
->
getCacheBackend
(
$bin
)
->
set
(
'test'
,
$this
->
defaultValue
,
CACHE_PERMANENT
,
$tags
);
$this
->
getCacheBackend
(
$bin
)
->
set
(
'test'
,
$this
->
defaultValue
,
C
acheBackendInterface
::
C
ACHE_PERMANENT
,
$tags
);
$this
->
assertTrue
(
$this
->
checkCacheExists
(
'test'
,
$bin
),
'Cache item was set in bin.'
);
}
...
...
core/modules/update/update.module
View file @
4a677afc
...
...
@@ -750,8 +750,8 @@ function update_verify_update_archive($project, $archive_file, $directory) {
* The data to store.
* @param $expire
* One of the following values:
* - C
ACHE_PERMANENT: Indicates that the item should never be removed except
* by explicitly using _update_cache_clear().
* - C
acheBackendInterface::CACHE_PERMANENT: Indicates that the item should
*
never be removed except
by explicitly using _update_cache_clear().
* - A Unix timestamp: Indicates that the item should be kept at least until
* the given time, after which it will be invalidated.
*
...
...
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