Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository 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
die_coolen_jungs
our_own_cloud_project
Commits
8848b5f0
Commit
8848b5f0
authored
10 years ago
by
Joas Schilling
Browse files
Options
Downloads
Patches
Plain Diff
Add an array implementation of cache and use it if we are not debugging
parent
0d8b3afc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/private/memcache/arraycache.php
+71
-0
71 additions, 0 deletions
lib/private/memcache/arraycache.php
lib/private/memcache/factory.php
+1
-1
1 addition, 1 deletion
lib/private/memcache/factory.php
tests/lib/memcache/arraycache.php
+17
-0
17 additions, 0 deletions
tests/lib/memcache/arraycache.php
with
89 additions
and
1 deletion
lib/private/memcache/arraycache.php
0 → 100644
+
71
−
0
View file @
8848b5f0
<?php
/**
* Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace
OC\Memcache
;
class
ArrayCache
extends
Cache
{
/** @var array Array with the cached data */
protected
$cachedData
=
array
();
/**
* {@inheritDoc}
*/
public
function
get
(
$key
)
{
if
(
$this
->
hasKey
(
$key
))
{
return
$this
->
cachedData
[
$key
];
}
return
null
;
}
/**
* {@inheritDoc}
*/
public
function
set
(
$key
,
$value
,
$ttl
=
0
)
{
$this
->
cachedData
[
$key
]
=
$value
;
return
true
;
}
/**
* {@inheritDoc}
*/
public
function
hasKey
(
$key
)
{
return
isset
(
$this
->
cachedData
[
$key
]);
}
/**
* {@inheritDoc}
*/
public
function
remove
(
$key
)
{
unset
(
$this
->
cachedData
[
$key
]);
return
true
;
}
/**
* {@inheritDoc}
*/
public
function
clear
(
$prefix
=
''
)
{
if
(
$prefix
===
''
)
{
$this
->
cachedData
=
[];
return
true
;
}
foreach
(
$this
->
cachedData
as
$key
=>
$value
)
{
if
(
strpos
(
$key
,
$prefix
)
===
0
)
{
$this
->
remove
(
$key
);
}
}
return
true
;
}
/**
* {@inheritDoc}
*/
static
public
function
isAvailable
()
{
return
true
;
}
}
This diff is collapsed.
Click to expand it.
lib/private/memcache/factory.php
+
1
−
1
View file @
8848b5f0
...
...
@@ -42,7 +42,7 @@ class Factory implements ICacheFactory {
}
elseif
(
Memcached
::
isAvailable
())
{
return
new
Memcached
(
$prefix
);
}
else
{
return
new
Null
(
$prefix
);
return
new
ArrayCache
(
$prefix
);
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/lib/memcache/arraycache.php
0 → 100644
+
17
−
0
View file @
8848b5f0
<?php
/**
* Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace
Test\Memcache
;
class
ArrayCache
extends
Cache
{
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
instance
=
new
\OC\Memcache\ArrayCache
(
''
);
}
}
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