UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'lunEbIZCM5UQ7edR3vseHLInGmCehrjMy31555lutXc=' 
WHERE 
  key_id = '5aebabffa764cd6e5719b7a841e99b0a195934a816ed5e1948018c3eab19134d' 
  AND (
    token = 'lunEbIZCM5UQ7edR3vseHLInGmCehrjMy31555lutXc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034