UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QzKK0+dxGGQ7rmv6HC64QBTMjKB2CSgmm0ZhMctwuqo=' 
WHERE 
  key_id = 'd3984bd81b149e75fa5b65d1059895ca400ed89b1f31e0395c8f863ae10d49f3' 
  AND (
    token = 'QzKK0+dxGGQ7rmv6HC64QBTMjKB2CSgmm0ZhMctwuqo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032