Reputation: 1524
I'm a php developer. In .NET we are able to store data in server in one variable.
It's possible that we can store one array in apache server's & get that?
I'm now using php_memcache.dll on my WAMP
$memcache_obj = memcache_connect('localhost',80);
memcache_set($memcache_obj, 'var_key', 'some variable', MEMCACHE_COMPRESSED , 0);
echo memcache_get($memcache_obj, 'var_key');
when i'm doing this memcache_set return false & gives warning
Notice: memcache_set() [function.memcache-set]: Server localhost (tcp 80) failed with: Failed reading line from stream (0) in abc file
Upvotes: 0
Views: 1708
Reputation: 20550
I think there is a misunderstanding.
It's possible that we can store one array in apache server's & get that?
Not in Apache, but in memcached
(it is also a server, aka "memory cache daemon" == memcached).
Apache and memcached are different things. They co-exist.
I'm now using php_memcache.dll on my WAMP
Okay, this is the client library for memcache. It provides you the memcache_set()
and memcache_get()
functions in PHP.
It does not automatically provide a memcache server. Read here on how to setup memcache in a windows environment. Memcache is not originally developed to support windows, but there is a ported version of it.
Once set up correctly, you will need to change your first line:
$memcache_obj = memcache_connect('localhost',80);
Port 80 is HTTP, which is served by Apache - memcache runs on port 11211 in most default setups:
$memcache_obj = memcache_connect('localhost', 11211);
Upvotes: 1
Reputation: 188
In php5 it is possible to write to server variables (ie. $_SERVER['foo']), however it will be completely dropped at the next page request. For saving specific user variables, you can use the session_start() + $_SESSION methodology. Which, of course, will only work for that specific user. But to have a users actions set a variable; that can then be related to any other user on the site, without database storage, you'll need the usesage of applications such as memcached.
Upvotes: 0