UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'PkxCT78b1MqeMKioOy4mJBxfOyl7WiqMZ87+wnCGXFI=' 
WHERE 
  key_id = '9a8ac83fe358f57a310fda53b8cec521c269e942fd76508a22dcffa32241be22' 
  AND (
    token = 'PkxCT78b1MqeMKioOy4mJBxfOyl7WiqMZ87+wnCGXFI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037