UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'GS1lDd4t6kctjnTo5YjmauirvX+QOgRZT+ekg2hv750=' 
WHERE 
  key_id = '14d1a7b05ebeaeeddcbdd3e95df7bf369fd54c98a7bf5d0cabb3dff67aca08d1' 
  AND (
    token = 'GS1lDd4t6kctjnTo5YjmauirvX+QOgRZT+ekg2hv750=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00060