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
7ce9c6f2
Commit
7ce9c6f2
authored
Jun 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved comments in memcached cache driver.
parent
55e1055d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
18 deletions
+7
-18
file.php
system/cache/driver/file.php
+7
-18
No files found.
system/cache/driver/file.php
View file @
7ce9c6f2
<?php
namespace
System\Cache\Driver
;
<?php
namespace
System\Cache\Driver
;
class
File
implements
\System\Cache\Driver
{
class
Memcached
implements
\System\Cache\Driver
{
/**
/**
* All of the loaded cache items.
* All of the loaded cache items.
...
@@ -34,25 +34,14 @@ class File implements \System\Cache\Driver {
...
@@ -34,25 +34,14 @@ class File implements \System\Cache\Driver {
return
$this
->
items
[
$key
];
return
$this
->
items
[
$key
];
}
}
if
(
!
file_exists
(
APP_PATH
.
'cache/'
.
$key
))
$cache
=
\System\Memcached
::
instance
()
->
get
(
\System\Config
::
get
(
'cache.key'
)
.
$key
);
{
return
$default
;
}
$cache
=
file_get_contents
(
APP_PATH
.
'cache/'
.
$key
);
if
(
$cache
===
false
)
// --------------------------------------------------
// Has the cache expired? The UNIX expiration time
// is stored at the beginning of the file.
// --------------------------------------------------
if
(
time
()
>=
substr
(
$cache
,
0
,
10
))
{
{
$this
->
forget
(
$key
);
return
$default
;
return
$default
;
}
}
return
$this
->
items
[
$key
]
=
unserialize
(
substr
(
$cache
,
10
))
;
return
$this
->
items
[
$key
]
=
$cache
;
}
}
/**
/**
...
@@ -65,7 +54,7 @@ class File implements \System\Cache\Driver {
...
@@ -65,7 +54,7 @@ class File implements \System\Cache\Driver {
*/
*/
public
function
put
(
$key
,
$value
,
$minutes
)
public
function
put
(
$key
,
$value
,
$minutes
)
{
{
file_put_contents
(
APP_PATH
.
'cache/'
.
$key
,
(
time
()
+
(
$minutes
*
60
))
.
serialize
(
$value
),
LOCK_EX
);
\System\Memcached
::
instance
()
->
set
(
\System\Config
::
get
(
'cache.key'
)
.
$key
,
$value
,
0
,
$minutes
*
60
);
}
}
/**
/**
...
@@ -76,7 +65,7 @@ class File implements \System\Cache\Driver {
...
@@ -76,7 +65,7 @@ class File implements \System\Cache\Driver {
*/
*/
public
function
forget
(
$key
)
public
function
forget
(
$key
)
{
{
@
unlink
(
APP_PATH
.
'cache/'
.
$key
);
\System\Memcached
::
instance
()
->
delete
(
\System\Config
::
get
(
'cache.key'
)
.
$key
);
}
}
}
}
\ No newline at end of file
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