I think stackoverflow is better for this specific question.
Having said that most databases (on the backend) have spatial extension where you can run queries like 'where inside(point,geometry)'. So you create a bounding box or circle around the user, then run a query. That's faster than calculating distances between all users. The databases have special indices for geographic lookup.
Both point and geometry probably need to be specified in WKT format.
http://www.gaia-gis.it/spatialite-2.1/SpatiaLite-manual.htmlhttp://docs.mongodb.org/manual/applications/geospatial-index...