Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
8203bd9a
Commit
8203bd9a
authored
Jul 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring cache class.
parent
22c1353c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
cache.php
system/cache.php
+11
-13
No files found.
system/cache.php
View file @
8203bd9a
...
...
@@ -10,7 +10,10 @@ class Cache {
private
static
$drivers
=
array
();
/**
* Get a cache driver instance. Cache drivers are singletons.
* Get a cache driver instance. If no driver name is specified, the default
* cache driver will be returned as defined in the cache configuration file.
*
* Note: Cache drivers are managed as singleton instances.
*
* @param string $driver
* @return Cache\Driver
...
...
@@ -22,12 +25,9 @@ class Cache {
$driver
=
Config
::
get
(
'cache.driver'
);
}
if
(
!
array_key_exists
(
$driver
,
static
::
$drivers
))
{
static
::
$drivers
[
$driver
]
=
Cache\Factory
::
make
(
$driver
);
}
return
static
::
$drivers
[
$driver
];
return
(
array_key_exists
(
$driver
,
static
::
$drivers
))
?
static
::
$drivers
[
$driver
]
:
static
::
$drivers
[
$driver
]
=
Cache\Factory
::
make
(
$driver
);
}
/**
...
...
@@ -40,9 +40,7 @@ class Cache {
*/
public
static
function
get
(
$key
,
$default
=
null
,
$driver
=
null
)
{
$item
=
static
::
driver
(
$driver
)
->
get
(
$key
);
if
(
is_null
(
$item
))
if
(
is_null
(
$item
=
static
::
driver
(
$driver
)
->
get
(
$key
)))
{
return
is_callable
(
$default
)
?
call_user_func
(
$default
)
:
$default
;
}
...
...
@@ -51,8 +49,8 @@ class Cache {
}
/**
* Get an item from the cache. If
it doesn't exist, store the default valu
e
* in the cache and return it.
* Get an item from the cache. If
the item doesn't exist in the cache, stor
e
*
the default value
in the cache and return it.
*
* @param string $key
* @param mixed $default
...
...
@@ -60,7 +58,7 @@ class Cache {
* @param string $driver
* @return mixed
*/
public
static
function
maybe
(
$key
,
$default
,
$minutes
,
$driver
=
null
)
public
static
function
remember
(
$key
,
$default
,
$minutes
,
$driver
=
null
)
{
if
(
!
is_null
(
$item
=
static
::
get
(
$key
)))
{
...
...
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